結果

問題 No.1140 EXPotentiaLLL!
ユーザー IKyoproIKyopro
提出日時 2020-07-31 21:26:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 293 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 201,308 KB
実行使用メモリ 24,764 KB
最終ジャッジ日時 2023-09-20 21:31:49
合計ジャッジ時間 6,696 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 248 ms
24,524 KB
testcase_01 AC 245 ms
24,492 KB
testcase_02 AC 253 ms
24,656 KB
testcase_03 AC 225 ms
24,528 KB
testcase_04 AC 191 ms
24,704 KB
testcase_05 AC 257 ms
24,460 KB
testcase_06 AC 254 ms
24,676 KB
testcase_07 AC 293 ms
24,616 KB
testcase_08 AC 72 ms
24,656 KB
testcase_09 AC 70 ms
24,764 KB
testcase_10 AC 72 ms
24,680 KB
testcase_11 AC 67 ms
24,744 KB
testcase_12 AC 76 ms
24,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


int ma = 5000000;
vector<int> v(ma+1);
vector<int> prime;

void erast(){
    for(int i=0;i<=ma;i++){
        v[i] = 1;
    }
    for(int i=2;i*i<=ma;i++){
        if(v[i]){
            for(int j=0;i*(j+2)<=ma;j++){
                v[i*(j+2)]=0;
            }
        }
    }
    v[1] = false;
    for(int i=2;i<=ma;i++){
        if(v[i]){
            prime.push_back(i);
        }
    }
}

void solve(){
    ll A,P;
    cin >> A >> P;
    if(v[P]) cout << (A%P==0? 0:1) << "\n";
    else cout << -1 << "\n";
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    erast();
    int T;
    cin >> T;
    while(T--){
        solve();
    }
}
0