結果

問題 No.3015 アンチローリングハッシュ
ユーザー watchd0gwatchd0g
提出日時 2015-11-12 00:08:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 146,788 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-11 15:40:39
合計ジャッジ時間 4,269 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 WA -
testcase_22 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

unsigned long long get_hash(string s, unsigned long long a, unsigned long long b){
	unsigned long long hash = 0;

	for(int i = 0; i < s.size(); i++){
		hash = (hash * a + s[i]) % b;
	}

	return hash;
}

int main(){
	srand(time(NULL));
	string s,s2;
	int i,j,a,b;
	unsigned long long hash,hash2;
	cin >> a >> b;
	for(i=0;i<2;i++){
		s+=rand()%26 + 'a';
	}
	cout << s << endl;
	hash=get_hash(s,a,b);
	s2="aa";
	for(i=0;i<26;i++){
		s2[0]=s2[0]+i;
		for(j=0;j<26;j++){
			s2[1]='a'+j;
			hash2=get_hash(s2,a,b);
			if(s!=s2 && hash==hash2){
				cout << s2 << endl;
				break;
			}
		}
		if(s!=s2 && hash==hash2){
			break;
		}
	}
	return 0;
}
0