結果

問題 No.1140 EXPotentiaLLL!
ユーザー Haa
提出日時 2020-07-31 21:34:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 744 bytes
コンパイル時間 1,355 ms
コンパイル使用メモリ 167,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 16:50:24
合計ジャッジ時間 11,269 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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