結果

問題 No.7 プライムナンバーゲーム
ユーザー she11codeshe11code
提出日時 2015-05-06 02:18:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 1,298 bytes
コンパイル時間 1,350 ms
コンパイル使用メモリ 158,724 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 03:45:40
合計ジャッジ時間 2,257 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool sieve[10001];
bool dp[10001];

int main() {
    int n;
    cin >> n;

    int primes = 0;

    sieve[0] = sieve[1] = true;
    FOR(i, 2, n) {
        if (sieve[i]) continue;
        primes++;
        for (int j = i + i; j < n; j += i) {
            sieve[j] = true;
        }
    }

    /* 0 1 2 3 4 5 6 7 8 9 10 11 12
     * O O X X O O O O O O  O  X  X
     */

    dp[0] = dp[1] = true;
    FOR(i, 2, n+1) {
        for (int j = i; j >= 2; j--) {
            if (sieve[j]) continue;
            if (!dp[i-j]) {
                dp[i] = true;
                break;
            }
        }
    }

    cout << (dp[n] ? "Win" : "Lose") << endl;
}
0