random.cpp
#include <bits/stdc++.h> #define ULL unsigned long long #define LL long long using namespace std; ULL random(ULL mod){return ((ULL)rand() << 4 | (ULL)rand() << 19 | (ULL)rand() << 34 | (ULL)rand() << 49 | rand() & 15) % mod;} LL random(LL l,LL r){return random(r - l + 1) + l;} LL prandom(LL l,LL r,char c){LL ret = random(l, r); printf("%lld%c", ret, c); return ret;} int main(){ srand(time(NULL)); freopen("data.in", "w", stdout); //example int n = prandom(100, 200, ‘\n‘); for(int i=1; i<=n; i++) prandom(1, 10, " \n"[i==n]); int q = prandom(100, 200, ‘\n‘); for(int i=1; i<=q; i++){ int l = random(1, n), r = random(1, n); if(l > r) swap(l, r); printf("%d %d\n", l, r); } //example return 0; }
compare.cpp
#include <bits/stdc++.h> using namespace std; int main(){ int T = 100; for(int i=1; i<=T; i++){ system("random.exe"), system("right.exe"), system("wrong.exe"); if(system("fc data.ans data.out")) break; } return 0; }
wrong.cpp
... int main(){ freopen("data.in", "r", stdin); freopen("data.out", "w", stdout);
... return 0; }
right.cpp
... int main(){ freopen("data.in", "r", stdin); freopen("data.ans", "w", stdout); ... return 0; }
原文:https://www.cnblogs.com/PHDHD/p/14290018.html