結果

問題 No.1140 EXPotentiaLLL!
ユーザー HaaHaa
提出日時 2020-07-31 21:34:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 744 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 165,016 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 22:03:31
合計ジャッジ時間 12,392 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,163 ms
4,376 KB
testcase_01 AC 1,178 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 832 ms
4,380 KB
testcase_04 AC 643 ms
4,376 KB
testcase_05 AC 1,017 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 33 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

ll power(ll x, ll y, ll p) {
	if (y==0) return 1;
	else if (y==1) return x%p;
	else if (y%2==0) { ll pow=power(x,y/2,p); return (pow*pow)%p; } 
	else { ll pow=power(x,y/2,p); return ((pow*pow)%p)*x%p; }
}

int main() {
	int t; cin >> t;
	vector<bool> pr(5000001,1);
	for(int i=2;i<=5000000;i++){
		if(pr[i]){
			for(int j=i*2;j<=5000000;j+=i)
				pr[j]=0;
		}
	}
	while(t--){
		ll a, p; cin >> a >> p;
		if(pr[p])
			printf("1\n");
		else
			printf("-1\n");
	}
	return 0;
}
0