結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 deuteridayodeuteridayo
提出日時 2020-12-08 12:29:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 868 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 170,612 KB
実行使用メモリ 8,060 KB
最終ジャッジ日時 2023-10-17 17:09:14
合計ジャッジ時間 26,432 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,528 ms
8,032 KB
testcase_01 TLE -
testcase_02 AC 1,536 ms
8,032 KB
testcase_03 TLE -
testcase_04 AC 1,844 ms
8,032 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 AC 1,620 ms
8,032 KB
testcase_08 AC 1,326 ms
8,032 KB
testcase_09 AC 1,327 ms
8,032 KB
testcase_10 AC 1,324 ms
8,032 KB
testcase_11 AC 1,321 ms
8,032 KB
testcase_12 AC 1,321 ms
8,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
using lint = long long;
long const mod = 1e9+7;
//long const mod = 998244353;
vector<lint>pp;
void solve(){
    lint a,p;
    scanf("%lld %lld", &a, &p);
    if(!binary_search(pp.begin(),pp.end(), p)){
        cout << -1 << endl;
        return;
    }
    if(a%p==0){
        printf("%d\n",0);
        return;
    }else{
        printf("%d\n",1);
    }

    



}
int main(){
    pp.push_back(2);
    for(int i=3;i<=5000000;i+= 2){
        bool chk = true;
        for(int j = 0;j < pp.size(); j++){
            if(pp[j] > sqrt(i))break;
            if(i % pp[j] == 0){
                chk = false; 
                break;
            }
        }
        if(chk)pp.push_back(i);
    }
    lint t;
    scanf("%lld", &t);
    for(int i=0;i<t;i++){
        solve();
    }
}
0