結果

問題 No.1140 EXPotentiaLLL!
ユーザー cn_449cn_449
提出日時 2020-07-31 21:22:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 1,606 bytes
コンパイル時間 1,227 ms
コンパイル使用メモリ 128,072 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 21:22:21
合計ジャッジ時間 4,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 194 ms
4,376 KB
testcase_01 AC 190 ms
4,376 KB
testcase_02 AC 198 ms
4,380 KB
testcase_03 AC 134 ms
4,380 KB
testcase_04 AC 109 ms
4,380 KB
testcase_05 AC 158 ms
4,376 KB
testcase_06 AC 151 ms
4,380 KB
testcase_07 AC 193 ms
4,380 KB
testcase_08 AC 32 ms
4,380 KB
testcase_09 AC 32 ms
4,380 KB
testcase_10 AC 32 ms
4,376 KB
testcase_11 AC 32 ms
4,380 KB
testcase_12 AC 32 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

int N = 5000010;
vector<bool> prime(N, 1);

void init() {
	prime[0] = prime[1] = false;
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			for (int j = 2 * i; j < N; j += i) prime[j] = false;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	init();

	int t;
	cin >> t;
	while (t--) {
		ll a, p;
		cin >> a >> p;
		if (!prime[p]) cout << "-1\n";
		else if (a % p) cout << "1\n";
		else cout << "0\n";
	}
}
0