結果
| 問題 | No.726 Tree Game |
| コンテスト | |
| ユーザー |
aguroshou
|
| 提出日時 | 2018-08-25 00:05:02 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,867 bytes |
| 記録 | |
| コンパイル時間 | 1,332 ms |
| コンパイル使用メモリ | 166,748 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 16:18:00 |
| 合計ジャッジ時間 | 2,125 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
using namespace std;
using ll = long long;
typedef pair <int, int> pii;
bool IsPrime(ll num)
{
if (num < 2) return false;
else if (num == 2) return true;
else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
double sqrtNum = sqrt(num);
for (ll i = 3; i <= sqrtNum; i += 2)
{
if (num % i == 0)
{
// 素数ではない
return false;
}
}
// 素数である
return true;
}
int main()
{
//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
//cout << LONG_MAX << endl;
string s;
//long long n, A[1000000000];
int n, m, q;
//int y[100001], z[100001], x[10001] = {};
//pii y[100001];
//pair<int, float> pii[100001];
ll A[100001];
cin >> a;
if(a==2)
{
cout<<"Second"<<endl;
return 0;
}
b = 0;
while (b == 0)
{
b = 0;
//for (c = 2; c < a; c++)
if (IsPrime(a))
{
b = 1;
break;
}
d++;
a++;
}
if (d == 0)
{
f++;
b = 0;
a++;
while (!IsPrime(a))
{
a++;
d++;
}
}
else
{
d--;
}
cin >> a;
if(a==2)
{
cout<<"Second"<<endl;
return 0;
}
b = 0;
while (b == 0)
{
b = 0;
//for (c = 2; c < a; c++)
if (IsPrime(a))
{
b = 1;
break;
}
e++;
a++;
}
if (e == 0)
{
f++;
b = 0;
a++;
while (!IsPrime(a))
{
a++;
e++;
}
}
else
{
e--;
}
if (f==2)
{
cout << "Second" << endl;
}
else if ((d + e) % 2 == 0)
{
cout << "Second" << endl;
}
else
{
cout << "First" << endl;
}
////std::cout << std::fixed;
//cout << std::setprecision(20) << << endl;
//cout << d+1 << endl;
//cout << "" << endl;
return 0;
}
aguroshou