結果

問題 No.3015 アンチローリングハッシュ
ユーザー zutsuzutsu
提出日時 2022-05-14 20:59:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 581 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 8,924 KB
最終ジャッジ日時 2023-09-30 13:58:19
合計ジャッジ時間 6,649 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 19 ms
8,892 KB
testcase_02 AC 19 ms
8,724 KB
testcase_03 AC 20 ms
8,836 KB
testcase_04 AC 19 ms
8,828 KB
testcase_05 WA -
testcase_06 AC 22 ms
8,736 KB
testcase_07 AC 21 ms
8,672 KB
testcase_08 AC 130 ms
8,776 KB
testcase_09 AC 121 ms
8,672 KB
testcase_10 AC 329 ms
8,884 KB
testcase_11 AC 663 ms
8,732 KB
testcase_12 AC 434 ms
8,924 KB
testcase_13 AC 305 ms
8,740 KB
testcase_14 AC 98 ms
8,880 KB
testcase_15 AC 21 ms
8,740 KB
testcase_16 AC 656 ms
8,736 KB
testcase_17 AC 359 ms
8,892 KB
testcase_18 AC 166 ms
8,876 KB
testcase_19 AC 169 ms
8,736 KB
testcase_20 AC 167 ms
8,724 KB
testcase_21 AC 91 ms
8,728 KB
testcase_22 AC 34 ms
8,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
a,b = map(int, input().split())

def get_hash(s, a, b):
    h = 0
    for i in range(len(s)):
        h = (h * a + s[i]) % b
    return h

for n in range(1, b):
    S = [random.randint(97, 122) for _ in range(n)]
    S_hash = get_hash(S, a, b)
    for _ in range(b-n):
        T = [random.randint(97, 122) for _ in range(n)]
        if S_hash == get_hash(T, a, b) and S != T:
            ss = [chr(s) for s in S]
            print(''.join(ss))
            tt = [chr(t) for t in T]
            print(''.join(tt))
            break
    else:
        continue
    break
0