結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
|
提出日時 | 2020-08-22 04:30:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 827 bytes |
コンパイル時間 | 814 ms |
コンパイル使用メモリ | 92,720 KB |
実行使用メモリ | 8,444 KB |
最終ジャッジ日時 | 2024-10-15 06:42:36 |
合計ジャッジ時間 | 13,317 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 WA * 3 |
ソースコード
#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; }