結果

問題 No.1140 EXPotentiaLLL!
ユーザー hanbei_dayohanbei_dayo
提出日時 2020-07-31 22:09:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,091 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 96,064 KB
実行使用メモリ 8,484 KB
最終ジャッジ日時 2023-09-20 23:36:51
合計ジャッジ時間 26,077 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,734 ms
8,276 KB
testcase_01 AC 1,727 ms
8,396 KB
testcase_02 AC 1,743 ms
8,352 KB
testcase_03 AC 1,700 ms
8,356 KB
testcase_04 AC 1,673 ms
8,280 KB
testcase_05 AC 1,731 ms
8,280 KB
testcase_06 WA -
testcase_07 AC 1,764 ms
8,484 KB
testcase_08 AC 1,575 ms
8,284 KB
testcase_09 AC 1,572 ms
8,360 KB
testcase_10 AC 1,574 ms
8,352 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
 
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

bool prime[5000010];
void furui() {
	int i = 2;
	while (i <= 5000000) {
		int j = 2;
		while (j*j <= i && !prime[i]) {
			if (i%j == 0) {
				prime[i] = true;
				break;
			}
			else j++;
		}
		int z = 2;
		while (!prime[i]) {
			if (i*z <= 5000000) {
				prime[i*z] = true;
				z++;
			}
			else break;
		}
		i++;
	}
}

int main(void){
	int T;
	scanf("%d",&T);
	furui();
	for(int i=0;i<T;i++){
		ll a,p;
		scanf("%ld%ld",&a,&p);
		if(prime[p])printf("-1\n");
		else{
			if(a%p==0)printf("0\n");
			else printf("1\n");
		}
	}
	return 0;
}
0