結果

問題 No.726 Tree Game
ユーザー donkorin_donkorin_
提出日時 2018-09-09 17:36:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,887 bytes
コンパイル時間 1,538 ms
コンパイル使用メモリ 169,480 KB
実行使用メモリ 48,580 KB
最終ジャッジ日時 2023-08-25 04:18:05
合計ジャッジ時間 8,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 182 ms
47,524 KB
testcase_01 AC 193 ms
47,000 KB
testcase_02 AC 175 ms
46,416 KB
testcase_03 AC 181 ms
47,252 KB
testcase_04 AC 182 ms
48,088 KB
testcase_05 AC 184 ms
47,780 KB
testcase_06 WA -
testcase_07 AC 188 ms
46,392 KB
testcase_08 AC 182 ms
46,772 KB
testcase_09 WA -
testcase_10 AC 191 ms
47,032 KB
testcase_11 WA -
testcase_12 AC 194 ms
48,048 KB
testcase_13 AC 187 ms
46,572 KB
testcase_14 AC 186 ms
47,212 KB
testcase_15 AC 196 ms
47,080 KB
testcase_16 WA -
testcase_17 AC 183 ms
47,556 KB
testcase_18 WA -
testcase_19 AC 180 ms
47,336 KB
testcase_20 WA -
testcase_21 AC 179 ms
46,748 KB
testcase_22 WA -
testcase_23 AC 180 ms
46,484 KB
testcase_24 AC 177 ms
47,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

vector<int> makePrimes(int n) {
    vector<int> res, pr(n + 1, 1);
    pr[0] = pr[1] = 0;
    rep(p, 2, sqrt(n) + 2) 
      if (pr[p]) 
      for (int x = p * 2; x <= n; x += p) pr[x] = 0;
    rep(p, 2, n + 1) 
      if (pr[p]) 
        res.push_back(p);
    return res;
}

bool isPrime(int x)
{
    if (x < 2)
        return false;
    else if (x == 2)
        return true;
    else if (x % 2 == 0)
        return false;

    double sq = sqrt(x);
    for (int i = 3; i <= sq; i += 2)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int X, Y;   
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> Y >> X;
    auto primes = makePrimes(10000000);
    int rx, upy;
    rx = *lower_bound(all(primes), X);
    upy = *lower_bound(all(primes), Y);
    if (isPrime(X)) {
      cout << "Second" << endl;
      return 0;
    } else if (isPrime(Y)) {
      cout << "First" << endl;
      return 0;
    }
    int diff_y = upy - Y - 1, diff_x = rx - X - 1;
    if (diff_y > diff_x) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}
0