結果

問題 No.726 Tree Game
ユーザー chocobochocobo
提出日時 2018-08-25 01:02:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,132 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 95,076 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 21:42:48
合計ジャッジ時間 1,971 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



int main() {
    ll y, x;
    cin >> y >> x;

    if(y == 2 || x == 2){
        cout << "Second" << endl;
        return 0;
    }

    bool f1 = false;
    if(y == 2 || y == 3){
        f1 = true;
    }
    else if(y > 3){
        ll i;
        for(i = 2; i <= ceil(sqrt(y)); i++){
            if(y % i == 0){
                break;
            }
        }
        if(i == ceil(sqrt(y)) + 1){
            f1 = true;
        }
    }

    bool f2 = false;
    if(x == 2 || x == 3){
        f2 = true;
    }
    else if(x > 3){
        ll i;
        for(i = 2; i <= ceil(sqrt(x)); i++){
            if(x % i == 0){
                break;
            }
        }
        if(i == ceil(sqrt(x)) + 1){
            f2 = true;
        }
    }

    if(f1 && f2){
        cout << "Second" << endl;
        return 0;
    }
    

    ll a;
    if(y > 2){
        for(a = y + 1;; a++){
            ll i;
            for(i = 2; i <= ceil(sqrt(a)); i++){
                if(a % i == 0){
                    break;
                }
            }
            if(i == ceil(sqrt(a)) + 1){
                break;
            }
        }
    }
    else{
        a = y + 1;
    }
    
    ll b;
    if(x > 2){
        for(b = x + 1;; b++){
            ll i;
            for(i = 2; i <= ceil(sqrt(b)); i++){
                if(b % i == 0){
                    break;
                }
            }
            if(i == ceil(sqrt(b)) + 1){
                break;
            }
        }
    }
    else{
        b = x + 1;
    }

    if(((a - y - 1) + (b - x - 1)) % 2 == 0){
        cout << "Second" << endl;
    }
    else{
        cout << "First" << endl;
    }
}
0