题解:P12199 Hash Killer III【Open Problem】
yaochenchen · · 题解
【Hash Killer III】一个蒟蒻的5分代码
非常朴素的想法:使用20组固定的 mod1 和 mod2(都是 int32 范围内的素数),并为每个 base(从2到21)生成一个特殊字符串。最终将这些段连接起来输出。
其实就是在赌评测机恰好使用了这组固定的mod1和mod2组合。
结果。。真的赌对了
后来我又试了几次,都是0分,不过希望能够给一些人一点思路和突破口
代码 (提交记录):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string convert(unsigned long long M, int base, int l) {
string s;
while (M) {
int digit = M % base;
s.push_back('a' + digit);
M /= base;
}
while (s.size() < l) {
s.push_back('a');
}
reverse(s.begin(), s.end());
return s;
}
int main() {
vector<unsigned long long> mod1 = {
1000000007,
1000000009,
1000000021,
1000000033,
1000000087,
1000000093,
1000000097,
1000000103,
1000000121,
1000000181,
1000000207,
1000000223,
1000000241,
1000000271,
1000000289,
1000000297,
1000000321,
1000000349,
1000000363,
1000000403
};
vector<unsigned long long> mod2 = {
1000000009,
1000000021,
1000000033,
1000000087,
1000000093,
1000000097,
1000000103,
1000000121,
1000000181,
1000000207,
1000000223,
1000000241,
1000000271,
1000000289,
1000000297,
1000000321,
1000000349,
1000000363,
1000000403,
1000000421
};
int l = 62;
string s;
for (int i = 0; i < 20; i++) {
int base = i + 2;
unsigned long long M = mod1[i] * mod2[i];
string t = convert(M, base, l);
s += string(l, 'a');
s += t;
}
int n = s.size();
cout << n << " " << l << endl;
cout << s << endl;
return 0;
}