結果
| 問題 |
No.726 Tree Game
|
| コンテスト | |
| ユーザー |
aguroshou
|
| 提出日時 | 2018-08-25 00:05:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,867 bytes |
| コンパイル時間 | 1,045 ms |
| コンパイル使用メモリ | 64,048 KB |
| 最終ジャッジ日時 | 2024-11-14 20:35:51 |
| 合計ジャッジ時間 | 1,459 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘bool IsPrime(ll)’:
main.cpp:19:26: error: ‘sqrt’ was not declared in this scope
19 | double sqrtNum = sqrt(num);
| ^~~~
ソースコード
#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