結果
| 問題 |
No.8014 多項式ハッシュに関する教育的な問題
|
| ユーザー |
norioc
|
| 提出日時 | 2025-03-23 23:06:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 443 bytes |
| コンパイル時間 | 277 ms |
| コンパイル使用メモリ | 82,320 KB |
| 実行使用メモリ | 340,980 KB |
| 最終ジャッジ日時 | 2025-03-23 23:06:46 |
| 合計ジャッジ時間 | 13,321 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | MLE * 1 |
ソースコード
from string import ascii_lowercase
import random
def myhash(s: str, b, mod):
h = 0
for c in s:
h = h*b + ord(c)
h %= mod
return h
def gen_str(n: int) -> str:
return ''.join(random.choices(ascii_lowercase, k=n))
P = int(input())
B = int(input())
used = {}
k = 20
while 1:
s = gen_str(k)
h = myhash(s, B, P)
if h in used:
print(s)
print(used[h])
break
used[h] = s
norioc