結果

問題 No.8015 アンチローリングハッシュ
ユーザー zutsu
提出日時 2022-05-14 20:59:07
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 581 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 398 ms
コンパイル使用メモリ 20,572 KB
実行使用メモリ 15,576 KB
最終ジャッジ日時 2026-04-03 13:20:58
合計ジャッジ時間 6,606 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge4_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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