結果

問題 No.3015 アンチローリングハッシュ
ユーザー zutsuzutsu
提出日時 2022-05-14 21:03:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,352 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 79,300 KB
最終ジャッジ日時 2023-09-30 14:03:30
合計ジャッジ時間 18,102 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
72,420 KB
testcase_01 AC 88 ms
71,980 KB
testcase_02 AC 87 ms
72,260 KB
testcase_03 AC 87 ms
72,256 KB
testcase_04 AC 418 ms
78,692 KB
testcase_05 AC 88 ms
72,216 KB
testcase_06 AC 413 ms
78,620 KB
testcase_07 AC 416 ms
78,516 KB
testcase_08 AC 454 ms
78,652 KB
testcase_09 AC 864 ms
79,032 KB
testcase_10 AC 1,326 ms
79,276 KB
testcase_11 AC 1,352 ms
79,132 KB
testcase_12 AC 1,253 ms
79,072 KB
testcase_13 AC 1,232 ms
79,064 KB
testcase_14 AC 1,266 ms
79,116 KB
testcase_15 AC 447 ms
78,872 KB
testcase_16 AC 1,310 ms
78,968 KB
testcase_17 AC 1,274 ms
79,300 KB
testcase_18 AC 436 ms
78,808 KB
testcase_19 AC 427 ms
78,620 KB
testcase_20 AC 424 ms
78,544 KB
testcase_21 AC 852 ms
79,056 KB
testcase_22 AC 425 ms
78,424 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, 10**6):
    S = [random.randint(97, 122) for _ in range(n)]
    S_hash = get_hash(S, a, b)
    for _ in range(10**6-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