結果

問題 No.1140 EXPotentiaLLL!
ユーザー 夜
提出日時 2020-08-22 04:30:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 827 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 94,036 KB
実行使用メモリ 8,552 KB
最終ジャッジ日時 2024-04-23 06:53:47
合計ジャッジ時間 13,552 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,164 ms
8,488 KB
testcase_01 AC 1,164 ms
8,488 KB
testcase_02 AC 1,271 ms
8,472 KB
testcase_03 AC 978 ms
8,484 KB
testcase_04 AC 749 ms
8,352 KB
testcase_05 AC 1,209 ms
8,456 KB
testcase_06 WA -
testcase_07 AC 1,264 ms
8,528 KB
testcase_08 AC 35 ms
8,484 KB
testcase_09 AC 34 ms
8,428 KB
testcase_10 AC 36 ms
8,484 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
bool b[5000010] = { false };
long long gcd(long long a, long long b) {
	if (a % b == 0) {
		return (b);
	}
	else {
		return (gcd(b, a % b));
	}
}
int main() {
	for (int i = 2; i <= 5000000; i++) {
		if (!b[i]) {
			for (int j = i + i; j <= 5000000; j += i) {
				b[j] = true;
			}
		}
	}
	int t;
	cin >> t;
	long long a, p;
	for (int i = 0; i < t; i++) {
		cin >> a >> p;
		if (b[p]) {
			cout << "-1" << endl;
		}
		else {
			if (gcd(a, p) == 1) {
				cout << "1" << endl;
			}
			else {
				cout << "0" << endl;
			}
		}
	}
	return 0;
}
0