結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
![]() |
提出日時 | 2025-04-16 00:16:25 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,150 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 81,856 KB |
実行使用メモリ | 65,032 KB |
最終ジャッジ日時 | 2025-04-16 00:17:58 |
合計ジャッジ時間 | 2,399 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 WA * 9 |
ソースコード
def all_same(s): return all(c == s[0] for c in s) N = input().strip() if all_same(N): print(N) else: sum_d = sum(int(c) for c in N) g = 1 if sum_d % 9 == 0: g *= 9 elif sum_d % 3 == 0: g *= 3 all_even = all(int(c) % 2 == 0 for c in N) if all_even: non_zero = [c for c in N if c != '0'] if non_zero: all_div4 = all(int(c) % 4 == 0 for c in non_zero) if all_div4: digits_int = [int(c) for c in N] unique_a = set(digits_int) is_4_factor = True for a in unique_a: required = (-2 * a) % 4 for b in digits_int: if b % 4 != required: is_4_factor = False break if not is_4_factor: break if is_4_factor: g *= 4 else: g *= 2 else: g *= 2 else: g *= 2 if all(c in {'0', '5'} for c in N): g *= 5 print(g)