結果

問題 No.1140 EXPotentiaLLL!
ユーザー chocoruskchocorusk
提出日時 2020-07-31 21:24:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,203 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 126,656 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 21:26:38
合計ジャッジ時間 12,687 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,203 ms
4,376 KB
testcase_01 AC 1,194 ms
4,380 KB
testcase_02 AC 1,201 ms
4,376 KB
testcase_03 AC 875 ms
4,380 KB
testcase_04 AC 668 ms
4,376 KB
testcase_05 AC 1,062 ms
4,380 KB
testcase_06 AC 1,011 ms
4,376 KB
testcase_07 AC 1,174 ms
4,380 KB
testcase_08 AC 34 ms
4,380 KB
testcase_09 AC 33 ms
4,380 KB
testcase_10 AC 34 ms
4,376 KB
testcase_11 AC 34 ms
4,376 KB
testcase_12 AC 34 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int MAX=5000050;
bitset<MAX> isprime;
void sieve(){
	for(int i=3; i<MAX; i++, i++) isprime[i]=1;
	isprime[2]=1;
	for(int i=3; i<MAX; i++){
		if(isprime[i]){
			for(int j=(i<<1); j<MAX; j+=i) isprime[j]=0;
		}
	}
}
int main()
{
	sieve();
	int t; cin>>t;
	while(t--){
		ll a, p;
		cin>>a>>p;
		if(!isprime[p]){
			cout<<-1<<endl;
			continue;
		}
		if(a%p==0){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
	}
	return 0;
}
0