結果
| 問題 | 
                            No.8015 アンチローリングハッシュ
                             | 
                    
| ユーザー | 
                             kokoa1046
                         | 
                    
| 提出日時 | 2018-01-30 20:02:50 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 861 bytes | 
| コンパイル時間 | 329 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 24,372 KB | 
| 最終ジャッジ日時 | 2024-12-29 21:46:44 | 
| 合計ジャッジ時間 | 22,405 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 WA * 10 TLE * 6 | 
ソースコード
#!/usr/bin/env pypy3
# -*- coding: utf-8 -*-
import itertools
import random
import string
mydict=dict()
max=1000000
def compute_hash(s, a, b):
    h = 0
    n = len(s)
    for i, c in enumerate(s):
        h += ((ord(c) % b) * pow(a, n - 1 - i, b)) % b
        h %= b
    return h
def generate_random_string(digits, source=string.ascii_lowercase):
    return "".join(random.choice(source) for _ in range(digits))
def cycledetection(a,b):
    for i in range(max):
        #print(i)
        tmp=a**i%b
        if tmp in mydict:
            return 0,mydict[tmp]+i
        mydict[tmp]=i
def main():
    a, b = map(int, input().split())
    s, t = cycledetection(a, b)
    tmp=generate_random_string(t+1)
    print(tmp)
    tmp=list(tmp)
    x=tmp[s]
    y=tmp[t]
    tmp[s]=y
    tmp[t]=x
    
    print("".join(tmp))
if __name__ == '__main__':
    main()
            
            
            
        
            
kokoa1046