結果

問題 No.726 Tree Game
ユーザー Khiromu
提出日時 2018-08-24 22:21:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 1,676 ms
コンパイル使用メモリ 167,152 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 07:53:25
合計ジャッジ時間 2,276 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll y, x;
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 main() {
    cin>>y>>x;

    ll ans=0;
    if(IsPrime(y) || IsPrime(x)){
        cout<<"First"<<endl;
        return 0;
    }

    while(!IsPrime(y)){
        ans++;
        y++;
    }
    while(!IsPrime(x)){
        ans++;
        x++;
    }
    
    if(ans<=2) cout<<"Second"<<endl;
    else if((ans-2)%2==0) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
    return 0;
}
0