結果

問題 No.1140 EXPotentiaLLL!
ユーザー HaaHaa
提出日時 2020-07-31 21:43:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 1,385 ms
コンパイル使用メモリ 166,464 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 22:26:29
合計ジャッジ時間 4,916 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
4,380 KB
testcase_01 AC 187 ms
4,376 KB
testcase_02 AC 197 ms
4,376 KB
testcase_03 AC 136 ms
4,380 KB
testcase_04 AC 111 ms
4,376 KB
testcase_05 AC 159 ms
4,376 KB
testcase_06 AC 153 ms
4,376 KB
testcase_07 AC 192 ms
4,376 KB
testcase_08 AC 32 ms
4,376 KB
testcase_09 AC 32 ms
4,376 KB
testcase_10 AC 32 ms
4,380 KB
testcase_11 AC 32 ms
4,376 KB
testcase_12 AC 32 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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()

int main() {
	int t; scanf("%d",&t);
	vector<bool> pr(5000001,1);
	pr[1]=0;
	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; scanf("%ld %ld",&a,&p);
		if(pr[p]){
			if(a%p==0)
				printf("0\n");
			else
				printf("1\n");
		}
		else
			printf("-1\n");
	}
	return 0;
}
0