题目数据生成

~ 2024-11-30 11:07:31

前提

生成题目数据需要准备gen.cpp(数据生成器)和std.cpp(标准程序),同时上传到对应题目文件内 点击生成可以自动获得10组数据

gen.cpp编写

#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;


int main(int argc,char *argv[]){
	int i = stoi(argv[1]);//代码从系统获取当前是第几个测试数据
	
	random_device rd;//获取随机数种子
	mt19937 gen(rd());//根据MT算法初始化种子
	uniform_int_distribution<> t(1990, 2022);//获得1990到2022的整数分布,注意,这里得到的是分布!!!
//	double a = 1.5, b = 10.5;
//    uniform_real_distribution<> dist(a, b);获得1.5到10.5的浮点数分布
	//uniform_int_distribution<ull> n(11, ull(1e18));//获得11到1e18的整数分布
	
	ios::sync_with_stdio(0);//标准输入/输出同步
//当前数据范围是否需要变动(根据当前数据点编号)
//	switch (i) {
//	case 1 ... 2:
//		break;
//		case 3 ... 6: 
//		t.param(decltype(t)::param_type (1, ull(5e5)));
//		n.param(decltype(n)::param_type (11, ull(1e6)));
//		break;
//		case 7 ... 10: 
//		t.param(decltype(t)::param_type (ull(1e4), ull(5e5)));
//		n.param(decltype(n)::param_type (ull(1e10), ull(1e18)));
//		break;
//		
//	}
	int tt=t(gen);//t(gen)获得t分布的随机数
	printf("%d %d", tt,2022-tt);//将数据写入.in文件
	
	return 0;
}



我们会审查剪贴板内容,并对发布不合适内容的同学进行相应的处理