結果

問題 No.7 プライムナンバーゲーム
ユーザー PachicobuePachicobue
提出日時 2017-05-29 01:46:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 1,778 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 162,884 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:21:17
合計ジャッジ時間 2,672 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr int MAX = 10000;
bool isprime[MAX + 1];
bool win[MAX + 1];

int main()
{
    rep(i, MAX + 1)
    {
        isprime[i] = true;
    }
    for (int i = 2; i <= MAX; i++) {
        if (isprime[i]) {
            for (int j = 2; i * j <= MAX; j++) {
                isprime[i * j] = false;
            }
        }
    }

    int n;
    cin >> n;

    win[0] = true;
    win[1] = true;
    win[2] = false;
    win[3] = false;
    for (int i = 4; i <= n; i++) {
        win[i] = false;
        for (int j = 2; j <= i; j++) {
            if (isprime[j]) {
                if (not win[i - j]) {
                    win[i] = true;
                    break;
                }
            }
        }
    }
    if (win[n]) {
        cout << "Win" << endl;
    } else {
        cout << "Lose" << endl;
    }
    return 0;
}
0