結果

問題 No.7 プライムナンバーゲーム
ユーザー wakapaijazzwakapaijazz
提出日時 2020-02-16 18:12:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,075 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 197,908 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 03:38:07
合計ジャッジ時間 3,081 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

bool isPrime(int x){
    if(x==0 || x==1) return false;
    int rx = floor(sqrt(x));    
    rep3(i,2,rx){
        if(x%i==0) return false;
    }
    return true;
}

void Main(){
    int n;
    cin >> n;
    vector<bool> res(n+10);
    res[0] = res[1] = true;
    res[2] = false;
    rep3(i,3,n) {
        res[i] = false;
        rep3(j,2,i-2){
            if(!res[j] && isPrime(i-j)) res[i] = true;
            break;
        }
    }
    if(res[n]) cout << "Win" << endl;
    else cout << "Lose" << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}
0