結果

問題 No.8015 アンチローリングハッシュ
ユーザー koyumeishi
提出日時 2015-06-29 01:24:09
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 704 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 61,936 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-07 21:06:33
合計ジャッジ時間 4,194 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 TLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(get_hash(t,a,b) != hash_s){
		for(int k=0; k<3; k++){
			t[rand()%t.size()] = 'a' + rand()%26;
		}
	}

	cout << s << endl;
	cout << t << endl;
	return 0;
}
0