結果

問題 No.1140 EXPotentiaLLL!
ユーザー Example0911Example0911
提出日時 2020-07-31 21:53:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 978 bytes
コンパイル時間 1,762 ms
コンパイル使用メモリ 171,908 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-09-20 23:01:27
合計ジャッジ時間 5,967 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 205 ms
4,392 KB
testcase_01 AC 199 ms
4,376 KB
testcase_02 AC 214 ms
4,380 KB
testcase_03 AC 144 ms
4,476 KB
testcase_04 AC 123 ms
4,396 KB
testcase_05 AC 169 ms
4,376 KB
testcase_06 AC 159 ms
4,392 KB
testcase_07 AC 204 ms
4,380 KB
testcase_08 AC 26 ms
4,384 KB
testcase_09 AC 27 ms
4,380 KB
testcase_10 AC 27 ms
4,392 KB
testcase_11 AC 26 ms
4,376 KB
testcase_12 AC 26 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define endl '\n'
const int inf = 1e9 + 11;
int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
bool is_prime(long long n) {  // is n prime or not
	for (long long i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}
vector<bool> make_is_prime(int N) {
	vector<bool> prime(N + 1, true);
	if (N >= 0) prime[0] = false;
	if (N >= 1) prime[1] = false;
	for (int i = 2; i * i <= N; i++) {
		if (!prime[i]) continue;
		for (int j = i * i; j <= N; j += i) {
			prime[j] = false;
		}
	}
	return prime;
}
vector<bool>ab;
void solve() {
	ll a, p; cin >> a >> p;
	if (ab[p]) {
		if (a % p == 0) {
			cout << 0 << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
	else cout << -1 << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ab.resize(5000010);
	ab = make_is_prime(5000010);
	int t; cin >> t;
	rep(_, t) {
		solve();
	}
	return 0;
}
0