結果
| 問題 |
No.8014 多項式ハッシュに関する教育的な問題
|
| ユーザー |
norioc
|
| 提出日時 | 2025-03-23 23:05:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 443 bytes |
| コンパイル時間 | 523 ms |
| コンパイル使用メモリ | 81,980 KB |
| 実行使用メモリ | 404,404 KB |
| 最終ジャッジ日時 | 2025-03-23 23:05:52 |
| 合計ジャッジ時間 | 13,530 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = 10
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