結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 deuteridayodeuteridayo
提出日時 2020-12-08 12:30:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,585 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 1,828 ms
コンパイル使用メモリ 170,408 KB
実行使用メモリ 7,980 KB
最終ジャッジ日時 2023-10-17 17:09:44
合計ジャッジ時間 24,000 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,498 ms
7,980 KB
testcase_01 AC 1,495 ms
7,980 KB
testcase_02 AC 1,502 ms
7,980 KB
testcase_03 AC 1,499 ms
7,980 KB
testcase_04 AC 1,450 ms
7,980 KB
testcase_05 AC 1,545 ms
7,980 KB
testcase_06 AC 1,521 ms
7,980 KB
testcase_07 AC 1,585 ms
7,980 KB
testcase_08 AC 1,297 ms
7,980 KB
testcase_09 AC 1,298 ms
7,980 KB
testcase_10 AC 1,297 ms
7,980 KB
testcase_11 AC 1,297 ms
7,980 KB
testcase_12 AC 1,297 ms
7,980 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)){
        printf("%d\n",-1);
        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