|
| 1 | +#include <iostream> |
| 2 | +#include <sstream> |
| 3 | +#include <vector> |
| 4 | +#include <algorithm> |
| 5 | +#include <set> |
| 6 | +#include <map> |
| 7 | +#include <queue> |
| 8 | +#include <cstring> |
| 9 | +#include <climits> |
| 10 | +#include <cstdio> |
| 11 | +using namespace std; |
| 12 | +typedef pair<int,int> pi; |
| 13 | +typedef set<int> si; |
| 14 | +typedef vector<int> vi; |
| 15 | +typedef vector<vi> vvi; |
| 16 | +typedef vector<string> vs; |
| 17 | +typedef long long ll; |
| 18 | +#define sz size() |
| 19 | +#define mp(x, y) make_pair(x, y) |
| 20 | +#define ri(a, b) for(int i=((int)(a)); i < ((int)(b)); i++) // i -> [a, b) |
| 21 | +#define rie(a, b) for(int i=((int)(a)); i <= ((int)(b)); i++) // i -> [a, b] |
| 22 | +#define rj(a, b) for(int j=((int)(a)); j < ((int)(b)); j++) // j -> [a, b) |
| 23 | +#define rje(a, b) for(int j=((int)(a)); j <= ((int)(b)); j++) // j -> [a, b] |
| 24 | +#define rk(a, b) for(int k=((int)(a)); k < ((int)(b)); k++) // k -> [a, b) |
| 25 | +#define rke(a, b) for(int k=((int)(a)); k <= ((int)(b)); k++) // k -> [a, b] |
| 26 | +#define fi(b) for(int i=0; i < ((int)(b)); i++) // i -> [0, b) |
| 27 | +#define fie(b) for(int i=0; i <= ((int)(b)); i++) // i -> [0, b] |
| 28 | +#define fj(b) for(int j=0; j < ((int)(b)); j++) // j -> [0, b) |
| 29 | +#define fje(b) for(int j=0; j <= ((int)(b)); j++) // j -> [0, b] |
| 30 | +#define fk(b) for(int k=0; k < ((int)(b)); k++) // k -> [0, b) |
| 31 | +#define fke(b) for(int k=0; k < ((int)(b)); k++) // k -> [0, b] |
| 32 | +#define fle(b) for(int l=0; l <= ((int)(b)); l++) // l -> [0, b] |
| 33 | + |
| 34 | +class ThePermutationGameDiv2{ |
| 35 | + public: |
| 36 | + ll gcd(ll a, ll b) |
| 37 | + { |
| 38 | + for (;;) |
| 39 | + { |
| 40 | + if (a == 0) return b; |
| 41 | + b %= a; |
| 42 | + if (b == 0) return a; |
| 43 | + a %= b; |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + ll lcm(ll a, ll b) |
| 48 | + { |
| 49 | + ll temp = gcd(a, b); |
| 50 | + return (max(a, b) / temp) * min(a, b); |
| 51 | + } |
| 52 | + ll findMin(int N){ |
| 53 | + ll res = 1; |
| 54 | + for(ll i = 1; i <= N; i++){ |
| 55 | + res = lcm(res, i); |
| 56 | + } |
| 57 | + return res; |
| 58 | + } |
| 59 | + |
| 60 | + |
| 61 | +// BEGIN CUT HERE |
| 62 | + public: |
| 63 | + void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); } |
| 64 | + private: |
| 65 | + template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } |
| 66 | + void verify_case(int Case, const long long &Expected, const long long &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } |
| 67 | + void test_case_0() { int Arg0 = 2; long long Arg1 = 2LL; verify_case(0, Arg1, findMin(Arg0)); } |
| 68 | + void test_case_1() { int Arg0 = 3; long long Arg1 = 6LL; verify_case(1, Arg1, findMin(Arg0)); } |
| 69 | + void test_case_2() { int Arg0 = 6; long long Arg1 = 60LL; verify_case(2, Arg1, findMin(Arg0)); } |
| 70 | + void test_case_3() { int Arg0 = 11; long long Arg1 = 27720LL; verify_case(3, Arg1, findMin(Arg0)); } |
| 71 | + void test_case_4() { int Arg0 = 25; long long Arg1 = 26771144400LL; verify_case(4, Arg1, findMin(Arg0)); } |
| 72 | + |
| 73 | +// END CUT HERE |
| 74 | + |
| 75 | +}; |
| 76 | + |
| 77 | +// BEGIN CUT HERE |
| 78 | +int main(){ |
| 79 | + |
| 80 | + ThePermutationGameDiv2 ___test; |
| 81 | + ___test.run_test(-1); |
| 82 | +} |
| 83 | +// END CUT HERE |
0 commit comments