結果

問題 No.443 GCD of Permutation
ユーザー WSKRWSKR
提出日時 2020-09-23 15:40:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 10,700 KB
実行使用メモリ 8,564 KB
最終ジャッジ日時 2023-09-10 07:14:39
合計ジャッジ時間 2,465 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
8,000 KB
testcase_02 AC 17 ms
8,064 KB
testcase_03 AC 16 ms
7,948 KB
testcase_04 AC 17 ms
8,040 KB
testcase_05 AC 16 ms
7,912 KB
testcase_06 AC 16 ms
8,008 KB
testcase_07 AC 16 ms
7,956 KB
testcase_08 AC 16 ms
8,040 KB
testcase_09 AC 17 ms
7,916 KB
testcase_10 AC 16 ms
7,944 KB
testcase_11 WA -
testcase_12 AC 16 ms
8,060 KB
testcase_13 AC 16 ms
7,944 KB
testcase_14 RE -
testcase_15 AC 18 ms
7,996 KB
testcase_16 AC 17 ms
8,004 KB
testcase_17 AC 17 ms
7,952 KB
testcase_18 AC 20 ms
8,512 KB
testcase_19 AC 17 ms
8,012 KB
testcase_20 AC 19 ms
8,380 KB
testcase_21 AC 17 ms
8,104 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 19 ms
8,460 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 20 ms
8,372 KB
testcase_29 WA -
testcase_30 AC 19 ms
8,468 KB
testcase_31 AC 20 ms
8,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#gcd of permutation
from math import gcd


def main():
    s = input()
    a = list(map(int, list(s)))
    a.sort()
    N = len(a)
    if a[0] == a[-1]:
        print(int(s))
        return
    else:
        ans = 1
        #2
        ans *= min(gcd(a[i], 8) for i in range(N))
        #3
        ans *= gcd(sum(a), 9)
        #5
        if all(a[i] % 5 == 0 for i in range(N)):
            ans *= 5
        #7:impossible
        print(ans)
        return


if __name__ == "__main__":
    main()

0