結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | ふっぴー |
提出日時 | 2017-04-16 14:39:38 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 159 ms / 5,000 ms |
コード長 | 1,007 bytes |
コンパイル時間 | 1,600 ms |
コンパイル使用メモリ | 94,208 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-07-24 20:50:04 |
合計ジャッジ時間 | 4,491 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 154 ms
4,376 KB |
testcase_01 | AC | 153 ms
4,376 KB |
testcase_02 | AC | 159 ms
4,376 KB |
testcase_03 | AC | 154 ms
4,376 KB |
testcase_04 | AC | 152 ms
4,380 KB |
testcase_05 | AC | 152 ms
4,376 KB |
testcase_06 | AC | 153 ms
4,380 KB |
testcase_07 | AC | 153 ms
4,380 KB |
testcase_08 | AC | 152 ms
4,376 KB |
testcase_09 | AC | 154 ms
4,376 KB |
testcase_10 | AC | 152 ms
4,376 KB |
testcase_11 | AC | 153 ms
4,376 KB |
testcase_12 | AC | 156 ms
4,380 KB |
testcase_13 | AC | 157 ms
4,380 KB |
testcase_14 | AC | 158 ms
4,376 KB |
testcase_15 | AC | 158 ms
4,380 KB |
testcase_16 | AC | 157 ms
4,380 KB |
ソースコード
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #include<assert.h> #include<ctime> #include<cstdlib> #include<numeric> using namespace std; typedef long long ll; #define loop(i,a,b) for(int i=a;i<b;i++) #define rloop(i,a,b) for(int i=a;i>b;i--) const int inf=1e8; const ll INF=1e16; #define MOD 1000000007 #define mod 1000000009 int main(){ int n; cin>>n; vector<int> sosuu; sosuu.push_back(2); loop(i,3,10001){ int flag=0; loop(j,2,i){ if(i%j==0){ flag=1; } } if(flag==0){ sosuu.push_back(i); } } vector<int> kekka(2,1); loop(i,0,2){ kekka.push_back(-1); } loop(i,4,n+1){ int j=0; int flag=-1; while(sosuu[j]<i){ if(kekka[i-sosuu[j]]==-1){ flag=1; } j++; } kekka.push_back(flag); } if(kekka[n]==1){ cout<<"Win"<<"\n"; }else{ cout<<"Lose"<<"\n"; } }