結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-08 19:38:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 1,000 ms |
| コード長 | 444 bytes |
| コンパイル時間 | 390 ms |
| コンパイル使用メモリ | 82,452 KB |
| 実行使用メモリ | 62,068 KB |
| 最終ジャッジ日時 | 2024-07-23 19:37:14 |
| 合計ジャッジ時間 | 2,830 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 |
ソースコード
N = input()
l = list(map(int,list(N)))
dat = [0] * 10
s = set()
for i in l:
s.add(i)
import sys
if len(s) == 1:
print(N)
exit()
def gcd(a,b):
if b == 0:return a
while True:
r = a % b
a = b
b = r
if r == 0:return a
d = 0
for i in range(10):
for j in range(i+1,10):
if i in s and j in s:
d = gcd(d,j-i)
d *= 9
n = 0
for i in l:
n = (n * 10 + i) % d
print(gcd(n,d))