众所周知,对拍是一个非常重要的知识点,还能帮我们造数据。
可以检测出我们代码中的问题。
所以,我就以A-B问题为例,为大家写出对拍。
我的(错误)程序(my.cpp)
看客:作者你是不是故意的?!
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a>1000)cout<<a*2-b;
else cout<<a-b;
return 0;
}暴力程序(std.cpp)
看客:好好的A-B弄那么复杂干嘛……
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
while(b--)a-=1;
cout<<a;
return 0;
}制造随机数(data.cpp)
#include <bits/stdc++.h>
using namespace std;
int main(){
int seed=time(NULL);
srand(seed);
int a=rand()*rand()%1000001,b=rand()*rand()%1000001;
cout<<a<<' '<<b;
return 0;
}对拍程序(dp.cpp)
#include <bits/stdc++.h>
using namespace std;
int main(){
int t,s;
while(1){
system("data.exe > in.txt");
s=clock();//计算时间
system("my.exe < in.txt > out.txt");
t=clock();
system("std.exe < in.txt > std.txt");
if(system("fc out.txt std.txt"))break;//对比数据
printf("AC time: %d\n",t-s);//输出用时
}
printf("WA time: %d\n",t-s);
return 0;
}本蒟蒻的第一篇文章,还望大家多多支持。
如有不足之处,欢迎大家指出。
注意,rand()最高是五位数