結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
![]() |
提出日時 | 2020-09-23 15:49:17 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 573 bytes |
コンパイル時間 | 116 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-06-27 22:42:00 |
合計ジャッジ時間 | 2,032 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 RE * 10 |
ソースコード
#gcd of permutation from math import gcd def main(): s = input() M = int(s) a = list(map(int, list(s))) a = list(set(a)) a.sort() N = len(a) if a[0] == a[-1]: print(int(s)) return else: ans = 0 G = 0 for i in range(N): for j in range(i+1,N): G = gcd(G,9*(a[j]-a[i])) for i in range(1, G+1): if G % i == 0: if M % i == 0: ans = i print(ans) return if __name__ == "__main__": main()