結果

問題 No.443 GCD of Permutation
ユーザー titiatitia
提出日時 2023-05-11 00:40:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 359 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 10,700 KB
実行使用メモリ 8,684 KB
最終ジャッジ日時 2023-08-18 01:51:16
合計ジャッジ時間 1,995 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 20 ms
8,540 KB
testcase_02 WA -
testcase_03 AC 19 ms
8,592 KB
testcase_04 WA -
testcase_05 AC 19 ms
8,644 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 19 ms
8,620 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 20 ms
8,412 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 19 ms
8,684 KB
testcase_22 AC 19 ms
8,432 KB
testcase_23 AC 19 ms
8,540 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 19 ms
8,524 KB
testcase_28 WA -
testcase_29 AC 20 ms
8,476 KB
testcase_30 WA -
testcase_31 AC 20 ms
8,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from collections import Counter

S=input()
C=Counter(S)

ANS=0

for i in range(10):
    for j in range(i+1,10):
        if C[str(i)]>0 and C[str(j)]>0:
            if "i"==0:
                ANS=gcd(ANS,j)

            else:
                a=(10*j+i)-(10*i+j)
                ANS=gcd(ANS,a)

if ANS==0:
    print(S)
else:
    print(ANS)
0