結果
| 問題 |
No.8015 アンチローリングハッシュ
|
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-06-29 01:35:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 743 bytes |
| コンパイル時間 | 427 ms |
| コンパイル使用メモリ | 62,168 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-07 21:08:51 |
| 合計ジャッジ時間 | 4,856 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 TLE * 1 -- * 14 |
ソースコード
#include <iostream>
#include <string>
#include "assert.h"
#include <fstream>
#include <vector>
#include <ctime>
#include <cstdlib>
using namespace std;
unsigned long long get_hash(string s, int a, int b){
unsigned long long hash = 0;
for(int i=0; i<s.size(); i++){
hash = (hash * a + s[i])%b;
}
return hash;
}
int main(){
int a,b;
cin >> a >> b;
srand((unsigned)time(NULL));
string s(2*b, 'a');
for(int i=0; i<s.size(); i++){
s[i] = 'a' + rand()%26;
}
unsigned long long hash_s = get_hash(s,a,b);
string t(2*b, 'a');
while(1){
while(get_hash(t,a,b) != hash_s){
for(int k=0; k<3; k++){
t[rand()%t.size()] = 'a' + rand()%26;
}
}
if(s != t) break;
}
cout << s << endl;
cout << t << endl;
return 0;
}
koyumeishi