結果
問題 | No.726 Tree Game |
ユーザー | onakaT_Titai |
提出日時 | 2018-08-24 22:18:04 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,758 bytes |
コンパイル時間 | 837 ms |
コンパイル使用メモリ | 94,992 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 07:48:29 |
合計ジャッジ時間 | 1,600 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
ソースコード
#include <iostream> #include <fstream> #include <string> #include <cstring> #include <cmath> #include <cstdlib> #include <ctime> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <functional> #include <cctype> #include <list> #include <limits> //#include <boost/multiprecision/cpp_int.hpp> #define BIT(a) (1 << (a)) #define EPS (1e-10) using namespace std; //using namespace boost::multiprecision; const long long MOD = 1000000007; const int COUNTER_CLOCKWISE = 1; const int CLOCKWISE = -1; const int ONLINE_BACK = 2; const int ONLINE_FRONT = -2; const int ON_SEGMENT = 0; class DisjointSet{ public: vector<int> rank, p; DisjointSet(){} DisjointSet(int size){ rank.resize(size, 0); p.resize(size, 0); for (int i = 0; i < size; i++) makeSet(i); } void makeSet(int x){ p[x] = x; rank[x] = 0; } bool same(int x, int y){ return findSet(x) == findSet(y); } void unite(int x, int y){ link(findSet(x), findSet(y)); } void link(int x, int y){ if (rank[x] > rank[y]){ p[y] = x; }else{ p[x] = y; if (rank[x] == rank[y]){ rank[y]++; } } } int findSet(int x){ if (x != p[x]){ p[x] = findSet(p[x]); } return p[x]; } }; class Point{ public: double x, y; Point(double x = 0, double y = 0): x(x), y(y) {} Point operator+(Point p){return Point(x + p.x, y + p.y);} Point operator-(Point p){return Point(x - p.x, y - p.y);} Point operator*(double a){return Point(a * x, a * y);} Point operator/(double a){return Point(x / a, y / a);} bool operator < (const Point &p) const { return y != p.y ? y < p.y : x < p.x; } double norm(){return x * x + y * y;} }; typedef Point Vector; typedef vector<Vector> Polygon; double cross(Vector a, Vector b){ return a.x*b.y - a.y*b.x; } double dot(Vector a, Vector b){ return a.x * b.x + a.y * b.y; } int ccw(Point p0, Point p1, Point p2){ Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > EPS)return COUNTER_CLOCKWISE; if (cross(a, b) > -EPS)return CLOCKWISE; if (dot(a, b) < -EPS)return ONLINE_BACK; if (a.norm() < b.norm())return ONLINE_FRONT; return ON_SEGMENT; } Polygon andrewScan(Polygon s){ Polygon u, l; if (s.size() < 3) return s; sort(s.begin(), s.end()); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size()-1]); l.push_back(s[s.size()-2]); for (size_t i = 2; i < s.size(); i++){ for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){ u.pop_back(); } u.push_back(s[i]); } for (int i = (int)s.size() - 3; i >= 0; i--){ for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){ l.pop_back(); } l.push_back(s[i]); } reverse(l.begin(), l.end()); for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]); return l; } long long mod_pow(long long x, long long n){ long long res = 1; for(int i = 0;i < 60; i++){ if(n >> i & 1) res = res * x % MOD; x = x * x % MOD; } return res; } bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } int A, B; int check(void){ int na; int nb; for (int i = A;; i++){ na = i - 1; if (IsPrime(i)){ break; } } for (int i = B;; i++){ nb = i - 1; if (IsPrime(i)){ break; } } if ((na - A) + (nb - B) % 2) return 1; else return 0; } int main(){ int na, nb; int flag = 0; cin >> A >> B; if (IsPrime(A) && IsPrime(B)){ cout << "First" << endl; return 0; } if (IsPrime(A)){ flag = 1; A++; } if (IsPrime(B)){ flag = 1; B++; } if (flag){ if(check()) cout << "Second" << endl; else cout << "First" << endl; }else{ if(check()) cout << "First" << endl; else cout << "Second" << endl; } return 0; }