diff options
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | others/153x/053.py | 14 | ||||
-rwxr-xr-x | others/153x/060.py | 30 | ||||
-rwxr-xr-x | others/153x/061.py | 7 |
4 files changed, 52 insertions, 1 deletions
diff --git a/README.md b/README.md index b4261e2..9ec1ace 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Phiên bản các trình dịch sử dụng test: | -------- | ------------------ | | C | GNU GCC 4.9+ | | Pascal | Free Pascal 2.6.4+ | -| Python | Python 3.4+ | +| Python | Python 3.5+ | | Scheme | GNU Guile 2.0.11+ | Tất cả các bài làm được phát hành theo giấy phép [GPLv3](LICENSE), cho phép diff --git a/others/153x/053.py b/others/153x/053.py new file mode 100755 index 0000000..2a1e6e7 --- /dev/null +++ b/others/153x/053.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +with open('MAP.INP') as fi, open('MAP.OUT', 'w') as fo: + x = y = 0 + for i in fi.read().rstrip(): + if i == 'E': + x -= 1 + elif i == 'W': + x += 1 + elif i == 'N': + y -= 1 + else: + y += 1 + fo.write(('E' if x > 0 else 'W') * abs(x) + + ('N' if y > 0 else 'S') * abs(y) + '\n') diff --git a/others/153x/060.py b/others/153x/060.py new file mode 100755 index 0000000..bfbf0cc --- /dev/null +++ b/others/153x/060.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +from fractions import Fraction + + +def dec_div(n): + return n, l2, l5 + + +def decimal(fraction): + a, b, l2, l5 = fraction.numerator, fraction.denominator, 0, 0 + if b == 1: return '{}\n'.format(a) + while not b % 2: + b //= 2 + l2 += 1 + while not b % 5: + b //= 5 + l5 += 1 + b2, b5, finited = 2 ** l2, 5 ** l5, 10 ** max(l2, l5) + if b == 1: return '{}\n'.format(a / (b2*b5)) + finiten = a * finited // b2 // b5 // b + finite = str(finiten / finited).rstrip('0') + f = Fraction(a, b * b2 * b5) - Fraction(finiten, finited) + a, b, d9 = f.numerator, f.denominator // finited, 9 + while d9 % b: d9 = d9*10 + 9 + return '{}({})\n'.format(finite, a * d9 // b) + + +with open('DECIMAL.INP') as fi, open('DECIMAL.OUT', 'w') as fo: + for line in fi: + fo.write(decimal(Fraction(*map(int, line.split())))) diff --git a/others/153x/061.py b/others/153x/061.py new file mode 100755 index 0000000..1535ff9 --- /dev/null +++ b/others/153x/061.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +from collections import deque +with open('CLIST.INP') as fi, open('CLIST.OUT', 'w') as fo: + n, k, l = map(int, fi.readline().split()) + d = deque(map(int, fi.readline().split())) + d.rotate(int(fi.read()) * (l - k) % n) + print(*d, file=fo) |