結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | naimonon77 |
提出日時 | 2015-09-28 00:10:30 |
言語 | C++11 (gcc 11.4.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,341 bytes |
コンパイル時間 | 856 ms |
コンパイル使用メモリ | 67,616 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-26 17:03:25 |
合計ジャッジ時間 | 3,565 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cstring> #include <algorithm> #include <sstream> #include <map> #include <set> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef unsigned long long ull; typedef long double ld; /* ここからが本編 */ /* */ /* 入力開始! */ /* 入力終了! */ int a; int prime[10200] = {0}; bool win[10001] = {1,1,0,0,1,1,}; /* 0 1 2 3 4 5 */ int chikai(int key) { int left = 0,right = a,mid; while(left < right) { mid = (left+right)/2; if(prime[mid] == key) return mid; else if(key < prime[mid]) right = mid; else left = mid + 1; } if(prime[left] > key) return left-1; else return left; } void judge(int n) { int i,j,k,l; for(i=chikai(n);i>-1;i--) { if( win[ n - prime[i] ] == 0 ) { win[n] = 1; break; } } } int main(void) { int i,j,k,l; int n,m; prime[0] = 2; a = 1; for(i=3;i<=10100;i+=2) { k=0; for(j=3;j*j<=i;j+=2) { if(i%j==0) { k=1; break; } } if(k==0) prime[a++] = i; } REP(i,3,10100) judge(i); cin >> n; if(win[n]) printf("Win\n"); else printf("Lose\n"); return 0; }