結果

問題 No.1140 EXPotentiaLLL!
ユーザー takumattakumat
提出日時 2020-07-31 22:03:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,306 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 88,692 KB
実行使用メモリ 22,804 KB
最終ジャッジ日時 2023-09-20 23:23:38
合計ジャッジ時間 5,198 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 249 ms
22,568 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 76 ms
22,552 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 77 ms
22,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void eratosthenes(int targ, std::set<int>& primes)
{
	std::vector<int> is_prime(targ + 1, 1);

	for (int i = 2; i * i <= targ; i++) {
		if (is_prime[i]) {
			for (int j = 0; (i * (j + 2)) <= targ; j++) {
				is_prime[i * (j + 2)] = 0;
			}
			primes.insert(i);
		}
	}
}

static void exec()
{
	int T;
	get(T);

	std::set<int> primes;
	eratosthenes(5 * 1000000, primes);

	LLONG A;
	int P;
	while (T--) {
		scanf("%lld %d", &A, &P);

		LLONG ans = -1;
		if (primes.find(P) != primes.end()) {
			ans = 1;
		}
		printf("%lld\n", ans);
	}
}
0