zoukankan      html  css  js  c++  java
  • 对拍程序

    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;
    }
  • 相关阅读:
    Helm安装带验证的ElasticSearch 6.x 7.x 集群
    K8S权限控制,限制用户在多个namespace上的访问权限
    Helm安装spinnaker到k8s集群
    离线安装spinnaker到K8S集群
    Kubernetes之CronJob
    GO语言GIN框架入门
    Kubernetes kubectl 命令概述
    Kubernetes Service
    Kubernetes Ingress
    centos+Jenkins+maven搭建持续集成
  • 原文地址:https://www.cnblogs.com/PHDHD/p/14290018.html
Copyright © 2011-2022 走看看