結果

問題 No.1140 EXPotentiaLLL!
ユーザー leaf_1415leaf_1415
提出日時 2020-07-31 21:27:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 1,033 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 73,796 KB
実行使用メモリ 8,512 KB
最終ジャッジ日時 2023-09-20 21:33:31
合計ジャッジ時間 4,481 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 222 ms
8,252 KB
testcase_01 AC 215 ms
8,232 KB
testcase_02 AC 227 ms
8,304 KB
testcase_03 AC 180 ms
8,288 KB
testcase_04 AC 146 ms
8,512 KB
testcase_05 AC 212 ms
8,236 KB
testcase_06 AC 202 ms
8,248 KB
testcase_07 AC 242 ms
8,228 KB
testcase_08 AC 39 ms
8,236 KB
testcase_09 AC 39 ms
8,280 KB
testcase_10 AC 39 ms
8,240 KB
testcase_11 AC 39 ms
8,284 KB
testcase_12 AC 39 ms
8,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint T;
llint a, p;
bool prime[5000005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	prime[1] = true;
	for(int i = 2; i < 5000005; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 5000005; j+=i) prime[j] = true;
	}
	
	cin >> T;
	for(int t = 0; t < T; t++){
		cin >> a >> p;
		if(prime[p]) cout << -1 << "\n";
		else{
			if(a % p == 0) cout << 0 << "\n";
			else cout << 1 << "\n";
		}
	}
	flush(cout);

	return 0;
}
0