出測資模板

Polygon

https://oi-wiki.org/tools/testlib/generator/

Generater

#include "testlib.h" #include <iostream> using namespace std; int main(int argc, char* argv[]) { registerGen(argc, argv, 1); int n = atoi(argv[1]); cout << rnd.next(1, n) << " "; cout << rnd.next(1, n) << endl; }

一般模板

#include<bits/stdc++.h> #include <fstream> #include <cstdlib> #include <ctime> #include <random> using namespace std; const int k = 5; int main(){ mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ofstream file_in, file_out; for (int file_case = 1 ; file_case <= k ; file_case++) { // 寫in out檔案 ofstream file_in, file_out; file_in.open(to_string(file_case) + ".in"); file_out.open(to_string(file_case) + ".out"); // n筆測資 srand( time(NULL) ); int n = rng() % 10000; string str = to_string(n); str += '\n'; //記得要換行 file_in << str; // 下面為處理題目 while (n--) { int t = rng() % 0X3f3f3f3f; if (n == 5 || t == 0) t = 1; string st = to_string(t); st += '\n'; file_in << st; string out ; if (t == 1 || t % 2 == 0) { out = "No\n"; file_out << out ; continue; } bool ans = true; for (int i = 3 ; i * i <= t ; i+=2) { if (t % i == 0){ ans = false; break; } } if (ans) { out = "Yes\n"; file_out << out ; }else{ out = "No\n"; file_out << out ; } } file_in.close(); file_out.close(); } return 0; }