OI 批量数据生成器
OI 批量数据生成器
转载自:https://www.cnblogs.com/luoyibujue/p/10564832.html。
//批量生产测试数据
/*
By:fastle
用自己习惯的方式修改了代码。
生成 10 组 a+b problem 的数据。
*/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define problem "a" //输出文件名
#define prename "a" //更改之前的文件名
//=============================================================
char ak[1000];
const int cases = 10; //数据组数
const int mode = 1; //1 造数据 // 2重新编号
int getrand() {
return (rand() << 15) + rand() + 1;
}
LL getlong() {
return ((LL) getrand() << 31ll) + getrand();
}
//=============================================================
const int kMaxn = 1e5 + 10;
LL kLim[cases] = {1000, 1000, 1000, 1000, 10000000, 10000000, 10000000000000ll, 10000000000000ll, 10000000000000ll, 10000000000000ll};
void make_data(int test) {
LL A, B;
LL Lim = kLim[test - 1];
A = getrand() % Lim, B = getrand() % Lim;
printf("%lld %lld\n", A, B);
}
//=============================================================
int main() {
srand(time(0));
for (int a = 1; a <= cases; a++) {
fprintf(stderr, "%d\n", a);
if (mode == 1) {
//获得文件输入
sprintf(ak, problem "%d.in", a);
freopen(ak, "w", stdout);
make_data(a);
fclose(stdout);
//获得文件输出,需要保证目录下存在同名标程。
#ifdef unix
sprintf(ak, "./" problem " < " problem "%d.in > " problem "%d.out", a, a);
#else
sprintf(ak, problem ".exe < " problem "%d.in > " problem "%d.out", a, a);
#endif
system(ak);
}
if (mode == 2) {
#ifdef unix
sprintf(ak, "mv " prename "%d.in " problem "%d.in", a, a);
#else
sprintf(ak, "rename " prename "%d.in " problem "%d.in", a, a);
#endif
system(ak);
#ifdef unix
sprintf(ak, "mv " prename "%d.out " problem "%d.out", a, a);
#else
sprintf(ak, "rename " prename "%d.out " problem "%d.out", a, a);
#endif
system(ak);
}
}
return 0;
}
作者@Luckyblock,转载请声明出处。