結果
問題 | No.443 GCD of Permutation |
ユーザー |
![]() |
提出日時 | 2025-06-12 21:32:06 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 556 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 82,288 KB |
実行使用メモリ | 63,252 KB |
最終ジャッジ日時 | 2025-06-12 21:33:36 |
合計ジャッジ時間 | 2,818 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 WA * 5 |
ソースコード
import sys import math def all_same(s): return all(c == s[0] for c in s) def main(): s = sys.stdin.readline().strip() if all_same(s): print(s) return # Compute sum of digits total = sum(int(c) for c in s) # Compute GCD of non-zero digits g = 0 for c in s: d = int(c) if d != 0: if g == 0: g = d else: g = math.gcd(g, d) # Compute P and G P = g * 9 G = math.gcd(total, P) print(G) if __name__ == "__main__": main()