結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | wakapaijazz |
提出日時 | 2020-02-16 18:25:14 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 47 ms / 5,000 ms |
コード長 | 1,173 bytes |
コンパイル時間 | 2,124 ms |
コンパイル使用メモリ | 198,220 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-09 04:49:26 |
合計ジャッジ時間 | 3,221 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 47 ms
6,944 KB |
testcase_03 | AC | 4 ms
6,948 KB |
testcase_04 | AC | 2 ms
6,948 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 13 ms
6,944 KB |
testcase_07 | AC | 9 ms
6,944 KB |
testcase_08 | AC | 4 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,944 KB |
testcase_12 | AC | 32 ms
6,948 KB |
testcase_13 | AC | 34 ms
6,944 KB |
testcase_14 | AC | 46 ms
6,948 KB |
testcase_15 | AC | 44 ms
6,944 KB |
testcase_16 | AC | 40 ms
6,944 KB |
ソースコード
#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[i-j] && isPrime(j)) { res[i] = true; break; } } } //rep(i,n) if(res[i]) cout << i << endl; //* 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; }