結果

問題 No.726 Tree Game
ユーザー mamekin
提出日時 2018-09-17 14:29:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,078 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 115,052 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 07:39:49
合計ジャッジ時間 1,704 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

bool primalityTest(long long n)
{
    if(n < 2)
        return false;
    for(long long i=2; i*i<=n; ++i){
        if(n % i == 0)
            return false;
    }
    return true;
}

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

    bool ans = false;
    for(;;){
        if(!primalityTest(y+1) && !primalityTest(x))
            ++ y;
        else if(!primalityTest(y) && !primalityTest(x+1))
            ++ x;
        else
            break;
        ans ^= true;
    }

    if(ans)
        cout << "First" << endl;
    else
        cout << "Second" << endl;

    return 0;
}
0