結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー |
![]() |
提出日時 | 2020-07-31 21:37:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 260 ms / 2,000 ms |
コード長 | 1,445 bytes |
コンパイル時間 | 2,038 ms |
コンパイル使用メモリ | 190,044 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 16:57:39 |
合計ジャッジ時間 | 6,059 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#define _GLIBCXX_DEBUG#include <bits/stdc++.h>#define FOR(i,a,b) for(ll i=a;i<b;i++)#define rep(i,n) FOR(i,0,n)#define ROF(i,a,b) for(ll i=a;i>=b;i--)#define per(i,a) ROF(i,a,0)#define pb push_backusing namespace std;using ll=long long;using ld=long double;using ch=char;typedef pair<ll,ll> P;typedef vector<ll> vl;typedef vector<vl> vvl;typedef vector<P> vP;typedef vector<ch> vc;typedef vector<vc> vvc;const ll MOD=1000000007;const ll MOD2=998244353;const ld PI=acos(-1);const ll INF=1e18;struct edge{ll to,cost;};struct edge2{ll from,to,cost;};template <typename T>bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false;}template <typename T>bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false;}int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int t=1;cin >> t;vector<bool> is_prime(5e6+1,true);is_prime[0]=is_prime[1]=false;rep(i,5e6+1){if(is_prime[i]){ll j=2*i;while(j<=5e6){is_prime[j]=false;j+=i;}}}rep(tt,t){ll A,P;cin >> A >> P;if(!is_prime[P]){cout << -1 << '\n';}else{if(A%P==0){cout << 0 << '\n';}else{cout << 1 << '\n';}}}}