結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
![]() |
提出日時 | 2020-07-31 23:49:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,149 ms / 2,000 ms |
コード長 | 1,066 bytes |
コンパイル時間 | 2,013 ms |
コンパイル使用メモリ | 194,556 KB |
最終ジャッジ日時 | 2025-01-12 11:57:15 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for (int i=0; i < (n); i++) using namespace std; using ll = long long; ll mod; int main(){ ios::sync_with_stdio(false); int testcase; cin>> testcase; vector<bool> vp(5000000+1,true); // set<ll> prime; for(int i=2; i*i<=5000000; i++){ ll x=i+i; if(vp[i]==false) continue; while(x<=5000000){ // if(i==3) cerr<< x << " "<<endl; vp[x]=false; x += i; } } // mod = 70; // cerr << pow_kai(3,4) << endl; // for(int i=2; i<100; i++){ // if(vp[i]==true){ // cerr << i << " "; // } // } while(testcase--){ ll A,P; cin>>A>>P; mod = P; // Aが素数かどうか。 bool pflg = false; if(vp[P]==true && P>=2){ pflg=true; }else{ cout << -1 << endl; continue; } // Pが素数の時 ll x = A % P; if(x>=1){ cout<< 1 << endl; }else{ cout << 0 << endl; } } }