結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー |
![]() |
提出日時 | 2020-07-31 21:25:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 205 ms / 2,000 ms |
コード長 | 583 bytes |
コンパイル時間 | 1,666 ms |
コンパイル使用メモリ | 169,720 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-06 16:14:50 |
合計ジャッジ時間 | 4,682 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;vector<bool> prime(5000001, true);prime[0] = false;prime[1] = false;for (int i = 2; i <= 5000000; i++){if (prime[i]){for (int j = i * 2; j <= 5000000; j += i){prime[j] = false;}}}for (int i = 0; i < T; i++){long long A;int P;cin >> A >> P;if (!prime[P]){cout << -1 << "\n";} else if (A % P == 0){cout << 0 << "\n";} else {cout << 1 << "\n";}}}