結果

問題 No.2593 Reorder and Mod 120
ユーザー LyricalMaestroLyricalMaestro
提出日時 2024-01-05 20:05:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,366 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 70,968 KB
最終ジャッジ日時 2024-01-05 20:05:13
合計ジャッジ時間 2,738 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
60,096 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 42 ms
60,104 KB
testcase_03 AC 44 ms
62,240 KB
testcase_04 AC 45 ms
62,240 KB
testcase_05 AC 40 ms
59,844 KB
testcase_06 AC 47 ms
62,364 KB
testcase_07 AC 34 ms
53,460 KB
testcase_08 AC 34 ms
53,460 KB
testcase_09 AC 36 ms
53,460 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 47 ms
62,356 KB
testcase_12 AC 48 ms
64,440 KB
testcase_13 AC 51 ms
68,860 KB
testcase_14 AC 49 ms
66,500 KB
testcase_15 AC 50 ms
68,808 KB
testcase_16 AC 48 ms
64,448 KB
testcase_17 AC 49 ms
64,404 KB
testcase_18 AC 48 ms
64,420 KB
testcase_19 AC 52 ms
68,848 KB
testcase_20 AC 53 ms
70,968 KB
testcase_21 AC 53 ms
70,968 KB
testcase_22 AC 53 ms
70,968 KB
testcase_23 AC 53 ms
70,968 KB
testcase_24 AC 50 ms
68,620 KB
testcase_25 AC 49 ms
68,620 KB
testcase_26 AC 51 ms
68,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


def main():
    N = int(input())
    S = input()

    if N >= 3:
        array = [0] * 10
        for s in S:
            array[int(s)] += 1

        r_set = set()
        for i1 in range(1, 10):
            for i2 in range(1, 10):
                for i3 in range(1, 10):
                    b_array = [0] * 10
                    b_array[i1] += 1
                    b_array[i2] += 1
                    b_array[i3] += 1
                    is_ok = True
                    for j in range(10):
                        if b_array[j] > array[j]:
                            is_ok = False
                            break

                    if is_ok:
                        b = i1 * 100 + i2 * 10 + i3
                        b %= 120

                        for j in range(1, 10):
                            c = array[j] - b_array[j]
                            d = (40 * j) % 120
                            d *= c
                            d %= 120
                            b += d
                            b %= 120
                        r_set.add(b)
        print(len(r_set))      
    else:
        # N <= 2 以下
        if N == 1:
            print(1)
        else:
            r_set = set()
            r_set.add(int(S))
            r_set.add(int(S[1]) * 10 + int(S[0]))
            print(len(r_set))




if __name__ == "__main__":
    main()
0