首页 > 系统服务 > 详细

Linux下对拍(A+B问题)

时间:2020-06-25 22:12:37      阅读:85      评论:0      收藏:0      [点我收藏+]

对拍代码

#include<bits/stdc++.h>
using namespace std;
int main(){
      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("data.in","w",stdout);
      srand(time(NULL));
      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;
}

Linux下对拍(A+B问题)

原文:https://www.cnblogs.com/liuchanglc/p/13192968.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!