結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
![]() |
提出日時 | 2016-12-25 01:18:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 737 bytes |
コンパイル時間 | 1,752 ms |
コンパイル使用メモリ | 167,432 KB |
実行使用メモリ | 10,020 KB |
最終ジャッジ日時 | 2024-12-14 18:43:29 |
合計ジャッジ時間 | 14,692 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 TLE * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int N,M; int P[10010]; void prime( int N ) { for( int i = N; i >= 2; i-- ) { bool flag = true; for( int j = 2; j * j <= i; j++ ) { if( i % j == 0 ) { flag = false; break; } } if( flag ) { P[M++]=i; } } } bool dfs( const int T, const int N){ if( N <= 1) return T^1; int i = 0; while(P[i] > N) i++; while(i < M ){ int x = P[i++]; if(T^dfs(T^1, N - x )) return T^1; } return T; } int main(){ cin >> N; prime( N ); cout << ( dfs( 0, N ) ? "Win" : "Lose" ) << endl; return 0; }