- 编程
pai
- 2024-10-21 10:07:52 @
data.cpp
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
using namespace std;
int n, w;
int ai;
int main(int argc, char *argv[])
{
int t = 10;
if(argc > 1)
{
t = atoi(argv[1]);
}
srand(time(0) + t);
n = rand() % 16 + 5;
w = rand() % 49 + 30;
cout << n << " " << w << endl;
for(int i = 1; i <= n; i++)
{
ai = rand() % 600;
cout << ai << " ";
}
cout << endl;
return 0;
}
pai.cpp
#include <iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
//1.compile 3 files
system("g++ brust.cpp -o brust -O2");
system("g++ opt.cpp -o opt -O2");
system("g++ data.cpp -o data -O2");
//2. make .in .ans .out
int n = 1000;
for(int i = 1;i <= n; i++)
{
char s[100];
sprintf(s, "data %d > pai.in", i);
system(s);
system("brust < pai.in > pai.ans");
system("opt < pai.in > pai.out");
if(system("fc pai.ans pai.out > null") == 0)
{
cout << i << " AC!" << endl;
}
else
{
cout << i << " WA!" << endl;
break;
}
}
return 0;
}
1 条评论
-
hehejushi LV 8 @ 2024-10-21 10:08:04
沙发!
- 1