結果

問題 No.8015 アンチローリングハッシュ
ユーザー kotatsugame
提出日時 2020-03-09 05:18:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 1,424 ms
コンパイル使用メモリ 83,812 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2024-11-07 20:43:57
合計ジャッジ時間 2,101 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<random>
using namespace std;
int a,b;
int get_hash(const string&s)
{
	long h=0;
	for(int i=0;i<s.size();i++)
	{
		h=(h*a+s[i])%b;
	}
	return h;
}
string mp[1<<17];
main()
{
	cin>>a>>b;
	const int LEN=1e2;
	mt19937 rng(114514);
	for(;;)
	{
		string now="";
		for(int i=0;i<LEN;i++)
		{
			now+=rng()%26+'a';
		}
		int h=get_hash(now);
		if(mp[h]=="")mp[h]=now;
		else if(mp[h]!=now)
		{
			cout<<mp[h]<<endl<<now<<endl;
			return 0;
		}
	}
}
0