結果

問題 No.443 GCD of Permutation
ユーザー rpy3cpprpy3cpp
提出日時 2017-01-31 00:29:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 7,980 KB
最終ジャッジ日時 2023-08-25 15:27:47
合計ジャッジ時間 2,591 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 15 ms
7,852 KB
testcase_02 AC 16 ms
7,876 KB
testcase_03 AC 15 ms
7,780 KB
testcase_04 AC 15 ms
7,852 KB
testcase_05 AC 15 ms
7,844 KB
testcase_06 AC 15 ms
7,852 KB
testcase_07 AC 16 ms
7,844 KB
testcase_08 AC 16 ms
7,780 KB
testcase_09 AC 16 ms
7,816 KB
testcase_10 AC 15 ms
7,792 KB
testcase_11 WA -
testcase_12 AC 16 ms
7,796 KB
testcase_13 AC 15 ms
7,784 KB
testcase_14 AC 18 ms
7,844 KB
testcase_15 AC 16 ms
7,976 KB
testcase_16 AC 16 ms
7,796 KB
testcase_17 AC 16 ms
7,772 KB
testcase_18 AC 17 ms
7,884 KB
testcase_19 AC 16 ms
7,792 KB
testcase_20 AC 18 ms
7,972 KB
testcase_21 AC 16 ms
7,840 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 18 ms
7,844 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 17 ms
7,852 KB
testcase_29 WA -
testcase_30 AC 17 ms
7,792 KB
testcase_31 AC 17 ms
7,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N):
    freq = [0] * 10
    lenN = len(N)
    for n in N:
        freq[int(n)] += 1
    if any(f == lenN for f in freq):
        return N
    two = 1
    if freq[1] + freq[3] + freq[5] + freq[7] + freq[9] == 0:
        two = 2
        if freq[2] + freq[6] == 0:
            two = 4
            if freq[4] == 0:
                two = 8
    pow3 = sum(f * i for i, f in enumerate(freq))
    three = 1
    if pow3 % 3 == 0:
        three = 3
        if pow3 % 9 == 0:
            three = 9
    five = 1
    if freq[0] + freq[5] == lenN:
        five = 5
    return two * three * five

N = input().rstrip()

print(solve(N))
0