結果

問題 No.8015 アンチローリングハッシュ
ユーザー zutsu
提出日時 2022-05-14 21:03:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,043 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 77,772 KB
最終ジャッジ日時 2024-07-23 08:06:50
合計ジャッジ時間 11,895 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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