結果

問題 No.443 GCD of Permutation
ユーザー ああいいああいい
提出日時 2022-03-08 19:38:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 1,000 ms
コード長 444 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 76,488 KB
最終ジャッジ日時 2023-10-01 02:07:02
合計ジャッジ時間 4,481 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,968 KB
testcase_01 AC 71 ms
71,200 KB
testcase_02 AC 77 ms
71,296 KB
testcase_03 AC 72 ms
71,152 KB
testcase_04 AC 73 ms
71,152 KB
testcase_05 AC 72 ms
71,140 KB
testcase_06 AC 72 ms
71,368 KB
testcase_07 AC 72 ms
70,692 KB
testcase_08 AC 73 ms
71,416 KB
testcase_09 AC 70 ms
71,272 KB
testcase_10 AC 70 ms
71,192 KB
testcase_11 AC 72 ms
70,848 KB
testcase_12 AC 72 ms
71,144 KB
testcase_13 AC 74 ms
71,364 KB
testcase_14 AC 91 ms
76,032 KB
testcase_15 AC 79 ms
76,360 KB
testcase_16 AC 77 ms
76,112 KB
testcase_17 AC 78 ms
76,484 KB
testcase_18 AC 78 ms
76,328 KB
testcase_19 AC 75 ms
76,328 KB
testcase_20 AC 77 ms
76,292 KB
testcase_21 AC 77 ms
76,104 KB
testcase_22 AC 73 ms
70,848 KB
testcase_23 AC 73 ms
71,152 KB
testcase_24 AC 74 ms
71,028 KB
testcase_25 AC 81 ms
75,968 KB
testcase_26 AC 80 ms
76,336 KB
testcase_27 AC 81 ms
76,488 KB
testcase_28 AC 79 ms
76,480 KB
testcase_29 AC 81 ms
76,360 KB
testcase_30 AC 82 ms
75,960 KB
testcase_31 AC 78 ms
76,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0