結果
問題 | No.1113 二つの整数 / Two Integers |
ユーザー |
![]() |
提出日時 | 2020-07-18 15:29:09 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 175 ms / 1,000 ms |
コード長 | 1,683 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-11-30 11:31:13 |
合計ジャッジ時間 | 1,950 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 |
ソースコード
from random import randintfrom collections import Counterdef gcd(x, y):while y:x, y = y, x % yreturn xdef miller_rabin(n, rep=100): #random.randintif n == 2: return Trueif n == 1 or n % 2 == 0: return Falsed = (n - 1) // 2while d % 2 == 0:d //= 2for k in range(rep):a = randint(1, n - 1)t = dy = pow(a, t, n)while t != n - 1 and y != 1 and y != n - 1:y = (y * y) % nt *= 2if y != n - 1 and t % 2 == 0:return Falsereturn Truedef factorize(n):if n == 1: return []res = []x, y = n, 2while y * y <= x:while x % y == 0:res.append(y)x //= yy += 1if x > 1:res.append(x)return resdef pollard_rho(n): #gcd, factorize, miller_rabinres = []stack = [n]while stack:tmp = stack.pop()if tmp < 10**10:res.extend(factorize(tmp))continueif miller_rabin(tmp):res.append(tmp)continueseed = 1while True:x, y, d = 2, 2, 1f = lambda x: (x**2 + seed) % tmpwhile d == 1:x = f(x)y = f(f(y))d = gcd(abs(x - y), tmp)if d != n:breakseed += 1stack.append(d)stack.append(tmp // d)return sorted(res)A, B = map(int, input().split())F = Counter(pollard_rho(A))G = Counter(pollard_rho(B))res = 1for k in F.keys():if k in G:res *= (min(F[k], G[k]) + 1)print('Even' if res % 2 == 0 else 'Odd')