結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
Dadarithm
|
| 提出日時 | 2015-10-04 22:04:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 468 ms / 5,000 ms |
| コード長 | 549 bytes |
| コンパイル時間 | 456 ms |
| コンパイル使用メモリ | 59,608 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 15:37:02 |
| 合計ジャッジ時間 | 1,845 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <iostream>
#include <cmath>
using namespace std;
bool prime(int n)
{
if (n < 2)
return false;
for (int i = 2; i <= sqrt(n); ++i)
{
if (n % i == 0)
return false;
}
return true;
}
bool dfs(int n, bool f, int counter)
{
if (n < 4) return counter % 2 == 0 ? f : !f;
int flag = false;
for (int i = 2; 1 < n - i; ++i)
{
if (prime(n - i))
{
if (!dfs(i, !f, counter + 1))
return true;
}
}
return false;
}
int main()
{
int res;
cin >> res;
cout << (dfs(res, false, 0) ? "Win" : "Lose") << endl;
return 0;
}
Dadarithm