結果

問題 No.7 プライムナンバーゲーム
ユーザー T1610T1610
提出日時 2018-01-19 02:18:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 1,248 bytes
コンパイル時間 1,854 ms
コンパイル使用メモリ 166,412 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:24:59
合計ジャッジ時間 2,766 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,820 KB
testcase_01 AC 8 ms
6,944 KB
testcase_02 AC 9 ms
6,944 KB
testcase_03 AC 9 ms
6,944 KB
testcase_04 AC 8 ms
6,948 KB
testcase_05 AC 8 ms
6,948 KB
testcase_06 AC 9 ms
6,944 KB
testcase_07 AC 9 ms
6,944 KB
testcase_08 AC 8 ms
6,944 KB
testcase_09 AC 9 ms
6,944 KB
testcase_10 AC 8 ms
6,944 KB
testcase_11 AC 9 ms
6,948 KB
testcase_12 AC 9 ms
6,948 KB
testcase_13 AC 9 ms
6,944 KB
testcase_14 AC 8 ms
6,948 KB
testcase_15 AC 8 ms
6,944 KB
testcase_16 AC 9 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

const int MAX_N = 10010;
vector<int> isPrime(MAX_N, 1);
vector<int> primes;

void buildPrime() {
    isPrime[0] = isPrime[1] = 0;
    for(int i = 2; i < MAX_N; ++i) {
        if(isPrime[i]) {
            primes.push_back(i);
            for(int j = i + i; j < MAX_N; j += i) {
                isPrime[j] = 0;
            }
        }
    }
}

int main(){
    buildPrime();
    int n;
    cin >> n;
    vector<int> win(MAX_N);
    win[0] = win[1] = 1;
    REP(i, 2, MAX_N) {
        int f = 0;
        for(int j = 0; j < primes.size() && primes[j] <= i; ++j) {
            if(win[i - primes[j]] == 0) f = 1;
        }
        win[i] = f;
    }
    cout << (win[n] ? "Win" : "Lose") << endl;
    return 0;
}
0