diff --git a/zeta_python/2981.py b/zeta_python/2981.py deleted file mode 100644 index 676a0e8..0000000 --- a/zeta_python/2981.py +++ /dev/null @@ -1,9 +0,0 @@ -N = int(input()) -I = sorted([int(input())for i in range(N)]) -p = min([(j-i) for i, j in zip(I, I[1:])]) -print(p) -T = [t for t in range(1, int(p**(1/2))+1) if p % t == 0] -if T[-1] == p // T[-1]: - print(" ".join([str(t) for t in T[1:-1]] + [str(p // t) for t in T[::-1]])) -else: - print(" ".join([str(t) for t in T[1:]] + [str(p // t) for t in T[::-1]])) diff --git a/zeta_python/completed/1676.py b/zeta_python/completed/1676.py new file mode 100644 index 0000000..b5aa85b --- /dev/null +++ b/zeta_python/completed/1676.py @@ -0,0 +1,20 @@ +def solve(N): + if N == 0 or N == 1: + return 0 + count2 = 0 + count5 = 0 + + for i in range(2, N + 1): + while i % 2 == 0 or i % 5 == 0: + if i % 2 == 0: + i //= 2 + count2 += 1 + elif i % 5 == 0: + i //= 5 + count5 += 1 + + return min((count2, count5)) + + +if __name__ == '__main__': + print(solve(int(input()))) diff --git a/zeta_python/completed/1676_shortcut.py b/zeta_python/completed/1676_shortcut.py new file mode 100644 index 0000000..85d7e21 --- /dev/null +++ b/zeta_python/completed/1676_shortcut.py @@ -0,0 +1,16 @@ +def solve(N): + if N == 0 or N == 1: + return 0 + count5 = 0 + + for i in range(5, N + 1, 5): + while i % 5 == 0: + if i % 5 == 0: + i //= 5 + count5 += 1 + + return count5 + + +if __name__ == '__main__': + print(solve(int(input()))) diff --git a/zeta_python/completed/2981.py b/zeta_python/completed/2981.py new file mode 100644 index 0000000..c089f54 --- /dev/null +++ b/zeta_python/completed/2981.py @@ -0,0 +1,32 @@ +def divisor(x): + divs = [] + for i in range(1, int(x ** (1 / 2)) + 1): + if x % i == 0: + divs.append(i) + for d in divs[::-1]: + t = x // d + if d == t: + continue + divs.append(x // d) + return divs + + +def gcd(x1, x2): + while x2 != 0: + temp = x1 % x2 + x1 = x2 + x2 = temp + return x1 + + +def solve(N, M): + M.sort() + last_night = M[1] - M[0] + for i in range(1, N - 1): + last_night = gcd(last_night, M[i + 1] - M[i]) + return " ".join(map(str, divisor(last_night)[1:])) + + +if __name__ == '__main__': + n = int(input()) + print(solve(n, list(map(int, (input() for i in range(n)))))) diff --git a/zeta_python/completed/3036.py b/zeta_python/completed/3036.py new file mode 100644 index 0000000..4afe6fe --- /dev/null +++ b/zeta_python/completed/3036.py @@ -0,0 +1,24 @@ +def fraction_ize(p, q): + while True: + # one process + for i in range(2, int(max((p, q)) ** (1 / 2)) + 1): + if q % i == 0: + if p % i == 0: + q //= i + p //= i + break + else: + break + return p, q + + +def solve(N, M): + chains = M[0] + T = [] + for i in range(1, N): + T.append(fraction_ize(chains, M[i])) + return "\n".join(f"{p}/{q}" for p, q in T) + + +if __name__ == '__main__': + print(solve(int(input()), list(map(int, input().split()))))