結果
| 問題 |
No.8015 アンチローリングハッシュ
|
| ユーザー |
peroon
|
| 提出日時 | 2019-04-15 21:39:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,592 bytes |
| コンパイル時間 | 1,140 ms |
| コンパイル使用メモリ | 109,428 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 08:03:14 |
| 合計ジャッジ時間 | 2,073 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
class Xorshift
{
private:
unsigned x, y, z, w;
public:
Xorshift(unsigned seed=88675123, int loop=50){
x = 123456789;
y = 362436069;
z = 521288629;
w = seed;
while(--loop >= 0){
(*this)();
}
}
unsigned operator()(){
unsigned t=(x^(x<<11));
x=y; y=z; z=w;
return w=(w^(w>>19))^(t^(t>>8));
}
unsigned operator()(unsigned size){
return (*this)() % size;
}
};
Xorshift xorshift;
long long getHash(const string& s, int a, int b)
{
int n = s.size();
long long hash = 0;
for(int i=0; i<n; ++i){
hash *= a;
hash += s[i];
hash %= b;
}
return hash;
}
int main()
{
int a, b;
cin >> a >> b;
map<long long, string> memo;
for(;;){
int n = 100;
string s(n, ' ');
for(int i=0; i<n; ++i)
s[i] = xorshift(26) + 'a';
long long hash = getHash(s, a, b);
auto it = memo.find(hash);
if(it != memo.end()){
cout << it->second << endl << s << endl;
return 0;
}
memo[hash] = s;
}
}
peroon