• 对拍程序


    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, '
    ');
        for(int i=1; i<=n; i++) printf("(%.2lf,%.2lf)
    ", 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
    ", 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
    ", 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
    ", a, b);
            }
            else if(op == 4){
                double a = randouble(0, 50, 2), b = randouble(0, 50, 2);
                printf("%.2lf %.2lf
    ", 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
    ", 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;
    }
  • 相关阅读:
    Java 高阶 —— try/catch
    Java 高阶 —— native 关键字与 JNI
    python库学习笔记——分组计算利器:pandas中的groupby技术
    编程模式(schema) —— 表驱动法(table-driven)
    python中元组tuple
    .Net Framwork类库
    SMB带宽限制
    WindDbug应用
    Python学习笔记
    Python递归遍历目录下所有文件
  • 原文地址:https://www.cnblogs.com/PHDHD/p/14290018.html
Copyright © 2020-2023  润新知