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 exp10[7] = {1, 10, 100, 1000, 10000, 100000, 1000000};
double randouble(double l,double r,int bit){return (double)random(l*exp10[bit], r*exp10[bit]) / exp10[bit];}

int main(){
    srand(time(NULL));
    freopen("data.in", "w", stdout);
    //example
    int n = prandom(200000-100, 200000, ' '), m = prandom(200000-100, 200000, '\n');
    for(int i=1; i<=n; i++) printf("(%.2lf,%.2lf)\n", randouble(0, 50, 2), randouble(0, 50, 2));
    for(int i=1; i<=m; i++){
        int op = random(1, 3), l = random(1, n), r = random(1, n);
        if(l > r) swap(l, r); if(op >= 2) op++;
        printf("%d %d %d ", op, l, r);
        if(op == 1){
            double a = randouble(0, 50, 2), b = randouble(0, 50, 2);
            printf("%.2lf %.2lf\n", a, b);
        }
        else if(op == 2){
            double a = randouble(0, 50, 2), b = randouble(0, 50, 2), arg = randouble(0, 3.14, 2);
            printf("%.2lf %.2lf %.2lf\n", a, b, arg);
        }
        else if(op == 3){
            double a = randouble(0.50, 1.50, 2), b = randouble(0.50, 1.50, 2);
            printf("%.2lf %.2lf\n", a, b);
        }
        else if(op == 4){
            double a = randouble(0, 50, 2), b = randouble(0, 50, 2);
            printf("%.2lf %.2lf\n", a, b);
        }
        else if(op == 5){
            double a = randouble(0.01, 50, 2), b = randouble(0.01, 50, 2), c = randouble(0.01, 50, 2);
            printf("%.2lf %.2lf %.2lf\n", a, b, c);
        }
    }
    //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;
}
posted on 2021-01-17 20:16  PHDHD  阅读(55)  评论(0编辑  收藏  举报