結果

問題 No.726 Tree Game
ユーザー aguroshouaguroshou
提出日時 2018-08-25 00:05:02
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,867 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 62,804 KB
最終ジャッジ日時 2023-09-05 20:37:27
合計ジャッジ時間 1,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘bool IsPrime(ll)’:
main.cpp:19:19: error: ‘sqrt’ was not declared in this scope
  double sqrtNum = sqrt(num);
                   ^~~~
main.cpp:19:19: note: suggested alternative: ‘qsort’
  double sqrtNum = sqrt(num);
                   ^~~~
                   qsort

ソースコード

diff #

#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;
}
0