結果

問題 No.726 Tree Game
ユーザー RTIA1227RTIA1227
提出日時 2018-08-24 21:48:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,304 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 73,096 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 11:24:16
合計ジャッジ時間 1,606 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

bool sosu(LL n){
    if(n < 2){
        return false;
    }else if(n == 2){
        return true;
    }else if(n%2 == 0){
        return false;
    }else{
        for(LL i = 3; i <= n/i; i += 2){
            if(n%i == 0){
                return false;
            }
        }
    }
    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    LL a,b;
    cin >> a >> b;

    LL enda = -1;
    LL endb = -1;

    bool fraga = sosu(a);
    bool fragb = sosu(b);
    if(fraga && fragb){
        cout << "Second" << endl;
        return 0;
    }

    for(LL i = a+1; enda < 0; i += 2){
        if(i%2 == 0){
            i++;
        }
        if(sosu(i)){
            enda = i;
        }
    }
    
    for(LL i = b+1; endb < 0; i += 2){
        if(i%2 == 0){
            i++;
        }
        if(sosu(i)){
            endb = i;
        }
    }

    if((abs(enda - a) + abs(endb - b))%2 == 0){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }

    return 0;
}
0