Gym - 100801H Hash Code Hacker (构造)
Posted dwtfukgv
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Gym - 100801H Hash Code Hacker (构造)相关的知识,希望对你有一定的参考价值。
题意:求 n 个哈希值相同的串。
析:直接构造,通过取模来查找相同的串。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include <cmath> #include <stack> #include <sstream> #define debug() puts("++++"); #define gcd(a, b) __gcd(a, b) #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define freopenr freopen("in.txt", "r", stdin) #define freopenw freopen("out.txt", "w", stdout) using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> P; const int INF = 0x3f3f3f3f; const double inf = 0x3f3f3f3f3f3f; const double PI = acos(-1.0); const double eps = 1e-8; const int maxn = 1e5 + 50; const LL mod = 2147483648; const int dr[] = {-1, 0, 1, 0}; const int dc[] = {0, 1, 0, -1}; const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"}; int n, m; const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; inline bool is_in(int r, int c){ return r >= 0 && r < n && c >= 0 && c < m; } vector<string> v, ans; int main(){ freopen("hash.in", "r", stdin); freopen("hash.out", "w", stdout); v.push_back("edHs"); v.push_back("fEHs"); v.push_back("edIT"); for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) for(int k = 0; k < 3; ++k) for(int l = 0; l < 3; ++l) for(int o = 0; o < 3; ++o) for(int p = 0; p < 3; ++p) for(int q = 0; q < 3; ++q) ans.push_back("mENAGeS"+v[i]+v[j]+v[k]+v[l]+v[o]+v[p]+v[q]); scanf("%d", &n); for(int i = 0; i < n; ++i) cout << ans[i] << endl; return 0; }
以上是关于Gym - 100801H Hash Code Hacker (构造)的主要内容,如果未能解决你的问题,请参考以下文章
codeforces gym 101164 K Cutting 字符串hash
Code Forces Gym 100886J Sockets
Code Forces Gym 100971D Laying Cables(单调栈)