結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー |
👑 ![]() |
提出日時 | 2020-07-31 21:52:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,127 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 1,501 ms |
コンパイル使用メモリ | 168,980 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 17:44:04 |
合計ジャッジ時間 | 11,677 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i = 0; i < (int)(n); i++)#define repr(i,n) for(int i = (int)(n); i >= 0; i--)#define all(v) v.begin(),v.end()typedef long long ll;int main(){ll T;cin >> T;vector<bool> isPrime(5000005, true);isPrime[1] = false;for (ll i = 2; i <= 5000004; i++){if (isPrime[i]){for (ll j = 2; j * i <= 5000004; j++){isPrime[j * i] = false;}}}rep(i,T){ll A,P;cin >> A >> P;if (!isPrime[P]) cout << -1 << endl;else{if (A % P == 0) cout << 0 << endl;else cout << 1 << endl;}}}