Linux下对拍(A+B问题)

对拍代码

#include<bits/stdc++.h>
using namespace std;
int main(){
    system("g++ data.cpp -o data");
    system("g++ test.cpp -o test");
    system("g++ std.cpp -o std");
    for(int i=1;;i++){
        system("./data");
        system("./std");
        system("./test");
        if(system("diff test.out std.out")){
            printf("Wrong Answer! No:%d\n",i);
            break;
        } else {
            printf("Accepted. No:%d\n",i);
        }
    }
    return 0;
}

数据代码(data.cpp)

#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("/dev/urandom", "r", stdin);  
	srand(getchar()*getchar()*getchar()*time(0));
	freopen("data.in","w",stdout);
	int a=rand()%100+1;
	int b=rand()%100+1;
	printf("%d %d\n",a,b);
	return 0;
}

暴力代码(std.cpp)

#include<bits/stdc++.h>
using namespace std;
int main(){
      freopen("data.in","r",stdin);
      freopen("std.out","w",stdout);
      int a,b;
      scanf("%d%d",&a,&b);
      printf("%d\n",a+b);
      return 0;
}

测试代码(test.cpp)

#include<bits/stdc++.h>
using namespace std;
int main(){
      freopen("data.in","r",stdin);
      freopen("test.out","w",stdout);
      int a,b;
      scanf("%d%d",&a,&b);
      if(a%50==0){
            printf("%d\n",a);
            return 0;
      }
      printf("%d\n",a+b);
      return 0;
}
posted @ 2020-10-10 10:50  liuchanglc  阅读(418)  评论(0编辑  收藏  举报