結果

問題 No.1141 田グリッド
ユーザー ryoissyryoissy
提出日時 2020-07-31 21:35:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 1,380 ms
コンパイル使用メモリ 163,148 KB
実行使用メモリ 10,456 KB
最終ジャッジ日時 2023-09-20 22:05:21
合計ジャッジ時間 8,960 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int t;
bool prime[5000005];
ll fact[500005];

void solve(){
	ll a,p;
	scanf("%lld%lld",&a,&p);
	if(!prime[p]){
		printf("-1\n");
	}else if(a%p!=0LL){
		printf("1\n");
	}else{
		printf("0\n");
	}
}

int main(void){
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(ll i=2;i<=5000000;i++){
		if(prime[i]){
			for(int j=i*2;j<=5000000;j+=i){
				prime[j]=false;
			}
		}
	}
	scanf("%d",&t);
	for(int i=0;i<t;i++){
		solve();
	}
	return 0;
}
0