半自动数据生成器
注:生成器中含部分中文,如果编译运行后显示乱码,可尝试上网查询解决方法。
使用方法:
-
不要在意
__rand_1e9_(),因为这只是一个辅助函数; -
Rand()为加强版随机数,用法为long long Rand(long long a , long long b),并且支持 的超大数据范围; -
在
InMaker()中放入输入数据生成器(可根据传入的数据点编号 Cnt 进行输入数据分层),再在OutMaker()中放入求解代码(可根据传入的数据点编号Cnt进行数据分层求解); -
编译后运行,根据程序的提示输入相应的信息,程序会在你完成了输入文件格式和输出文件格式后,输出当前设定的格式。如果不满意,可以关闭生成器并重新编译运行,再次输入想要的格式。
#include<bits/stdc++.h>
#include<time.h>
#define UNICODE
using namespace std;
int TestNum; char FileName[10005]; string InFile_pre , InFile_lst , InFile_type , OutFile_pre , OutFile_lst , OutFile_type;
long long Rand(long long a , long long b);
void InMaker(int Cnt)
{
}
void OutMaker(int Cnt)
{
}
void StringToChar(string A , char B[]);
void Reset();
void MakeIn(int Cnt);
void MakeOut(int Cnt);
long long __rand_1e9_(long long a , long long b);
signed main() { Reset(); for(int i = 1 ; i <= TestNum ; i++) { MakeIn(i); } for(int i = 1 ; i <= TestNum ; i++) { MakeOut(i); } return 0; }
void StringToChar(string A , char B[]) { int LenA = A.length(); for(int i = 0 ; i < LenA ; i++) { B[i] = A[i]; } }
void Reset() { setlocale(LC_ALL , ""); srand((unsigned) time(NULL)); freopen("CON" , "r" , stdin); freopen("CON" , "w" , stdout); wcout << L"请输入测试点数目:"; cin >> TestNum; wcout << L'\n'; wcout << L"输入文件的前缀名(没有则用 NONE 代替)将为:"; cin >> InFile_pre; InFile_pre = (InFile_pre == "NONE" ? "" : InFile_pre); wcout << L"输入文件的后缀名(没有则用 NONE 代替)将为:"; cin >> InFile_lst; InFile_lst = (InFile_lst == "NONE" ? "" : InFile_lst); wcout << L"输入文件的文件类型名将为:"; cin >> InFile_type; wcout << L"输入文件名的格式将为:"; cout << InFile_pre << 1 << InFile_lst << '.' << InFile_type; wcout << L"\n\n"; wcout << L"输出文件的前缀名(没有则用 NONE 代替)将为:"; cin >> OutFile_pre; OutFile_pre = (OutFile_pre == "NONE" ? "" : OutFile_pre); wcout << L"输出文件的后缀名(没有则用 NONE 代替)将为:"; cin >> OutFile_lst; OutFile_lst = (OutFile_lst == "NONE" ? "" : OutFile_lst); wcout << L"输出文件的文件类型名将为:"; cin >> OutFile_type; wcout << L"输出文件名的格式将为:"; cout << OutFile_pre << 1 << OutFile_lst << '.' << OutFile_type; wcout << L"\n\n"; }
void MakeIn(int Cnt) { memset(FileName , 0 , sizeof(FileName)); string Num = ""; int a = Cnt; while(a) { Num += (char) (48 + a % 10); a /= 10; } reverse(Num.begin() , Num.end()); string NowString = InFile_pre + Num + InFile_lst + '.' + InFile_type; StringToChar(NowString , FileName); freopen(FileName , "w" , stdout); InMaker(Cnt); }
void MakeOut(int Cnt) { memset(FileName , 0 , sizeof(FileName)); string Num = ""; int a = Cnt; while(a) { Num += (char) (48 + a % 10); a /= 10; } reverse(Num.begin() , Num.end()); string NowString = InFile_pre + Num + InFile_lst + '.' + InFile_type; StringToChar(NowString , FileName); freopen(FileName , "r" , stdin); memset(FileName , 0 , sizeof(FileName)); NowString = OutFile_pre + Num + OutFile_lst + '.' + OutFile_type; StringToChar(NowString , FileName); freopen(FileName , "w" , stdout); OutMaker(Cnt); }
long long __rand_1e9_(long long a , long long b) { long long eps = (a <= 0 ? (-a + 5) : 0); long long newA = a + eps , newB = b + eps; long long fst = (long long) rand() * (long long) rand(); return fst % (newB - newA + 1) + newA - eps; }
long long Rand(long long a , long long b) { long long eps = (a <= 0 ? (-a + 5) : 0); long long newA = a + eps , newB = b + eps; long long fst = __rand_1e9_(1 , 1000000000) * __rand_1e9_(1 , 1000000000); return fst % (newB - newA + 1) + newA - eps; }