結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
cww
|
| 提出日時 | 2016-12-25 00:36:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,457 bytes |
| コンパイル時間 | 1,723 ms |
| コンパイル使用メモリ | 172,220 KB |
| 実行使用メモリ | 9,896 KB |
| 最終ジャッジ日時 | 2024-12-14 18:40:27 |
| 合計ジャッジ時間 | 14,770 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 2 |
ソースコード
//メモ化無し 速度実験
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int N;
vector<int> P;
void prime( int N )
{
for( int i = 2; i <= N; i++ )
{
bool flag = true;
for( int j = 2; j * j <= i; j++ )
{
if( i % j == 0 )
{
flag = false;
break;
}
}
if( flag )
{
P.emplace_back( i );
}
}
reverse( P.begin(), P.end() );
}
bool dfs( const int T, const int N )
{
if( N == 0 || N == 1 )
{
return T == 0 ? 1 : 0;
}
if ( T == 0 )
{
for( const auto &x : P )
{
if( N - x >= 0 )
{
if( dfs( 1, N - x ) ) return 1;
}
}
return 0;
}
else
{
for( const auto &x : P )
{
if( N - x >= 0 )
{
if( !dfs( 0, N - x ) ) return 0;
}
}
return 1;
}
}
int main()
{
//const auto startTime = std::chrono::system_clock::now();
cin >> N;
prime( N );
cout << ( dfs( 0, N ) ? "Win" : "Lose" ) << endl;
//const auto endTime = chrono::system_clock::now();
//const auto timeSpan = endTime - startTime;
//cout << chrono::duration_cast<chrono::milliseconds>(timeSpan).count() << "[ms]" << endl;
return 0;
}
cww