結果
問題 | No.1113 二つの整数 / Two Integers |
ユーザー |
![]() |
提出日時 | 2020-07-17 21:41:06 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,002 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 21,504 KB |
最終ジャッジ日時 | 2024-11-29 22:41:15 |
合計ジャッジ時間 | 10,162 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 TLE * 6 |
ソースコード
#!/usr/bin/env python3import collectionsimport functoolsimport mathdef prod(xs):return functools.reduce(lambda x, y: x * y, xs, 1)def factorize_trial_division(n):"""Compute the prime factorization of the given integer `n` by trial division.Returns: the prime factors as a list."""factors = []if n < 2:return factorsfor p in range(2, math.ceil(math.sqrt(n)) + 1):if p * p > n:breakwhile n % p == 0:factors.append(p)n //= pif n > 1:factors.append(n)return factorsdef is_even(a, b):g = math.gcd(a, b)fs = factorize_trial_division(g)ctr = collections.Counter(fs)num_ds = prod(p + 1 for p in ctr.values())return num_ds % 2 == 0def main():a, b = (int(z) for z in input().split())if is_even(a, b):print("Even")else:print("Odd")if __name__ == '__main__':main()