結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
|
提出日時 | 2020-08-22 04:35:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,274 ms / 2,000 ms |
コード長 | 841 bytes |
コンパイル時間 | 797 ms |
コンパイル使用メモリ | 92,392 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-10-15 06:43:03 |
合計ジャッジ時間 | 12,576 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#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; } } } b[1] = 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; }