結果

問題 No.1140 EXPotentiaLLL!
ユーザー hs0319boyhs0319boy
提出日時 2020-07-31 22:02:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,707 ms / 2,000 ms
コード長 1,329 bytes
コンパイル時間 1,652 ms
コンパイル使用メモリ 174,844 KB
実行使用メモリ 25,152 KB
最終ジャッジ日時 2023-09-20 23:21:40
合計ジャッジ時間 17,539 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,388 ms
24,644 KB
testcase_01 AC 1,389 ms
24,896 KB
testcase_02 AC 1,391 ms
24,964 KB
testcase_03 AC 1,313 ms
25,152 KB
testcase_04 AC 996 ms
25,124 KB
testcase_05 AC 1,512 ms
24,664 KB
testcase_06 AC 1,492 ms
24,896 KB
testcase_07 AC 1,707 ms
24,664 KB
testcase_08 AC 146 ms
19,984 KB
testcase_09 AC 147 ms
20,044 KB
testcase_10 AC 148 ms
19,868 KB
testcase_11 AC 149 ms
19,980 KB
testcase_12 AC 148 ms
19,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

set<ll> prime;

ll eratosthenes(ll x){
    vbo isprime(x+1,true);
    isprime[0]=false;
    isprime[1]=false;
    ll p=0;
    for(ll i=2;i<=x;i++){
        if(isprime[i]){
            p++;
            prime.insert(i);
            for(ll j=2*i;j<=x;j+=i)isprime[j]=false;
        }
    }
    return p;
}

int main(){
    int t;cin>>t;
    eratosthenes(5e6+10);
    ll a,p;vll ans;
    rep(i,t){
        cin>>a>>p;
        if(!prime.count(p)){
            ans.push_back(-1);
            continue;
        }
        a%=p;
        if(a==0)ans.push_back(0);
        else ans.push_back(1);
    }
    rep(i,ans.size())cout<<ans[i]<<endl;
}
0