結果

問題 No.1140 EXPotentiaLLL!
ユーザー catuppercatupper
提出日時 2020-07-31 21:29:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 1,052 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 9,044 KB
最終ジャッジ日時 2023-09-20 21:41:48
合計ジャッジ時間 4,131 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
8,836 KB
testcase_01 AC 177 ms
9,044 KB
testcase_02 AC 186 ms
8,772 KB
testcase_03 AC 140 ms
8,916 KB
testcase_04 AC 113 ms
8,796 KB
testcase_05 AC 170 ms
8,868 KB
testcase_06 AC 162 ms
8,808 KB
testcase_07 AC 194 ms
8,796 KB
testcase_08 AC 23 ms
8,760 KB
testcase_09 AC 23 ms
8,840 KB
testcase_10 AC 23 ms
8,836 KB
testcase_11 AC 23 ms
8,760 KB
testcase_12 AC 23 ms
8,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

bool is_prime[5500000];

void init(){
    fill(is_prime, is_prime + 5500000, true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2;i*i < 5500000;i++){
        if(!is_prime[i])continue;
        for(Int j = i * i;j < 5500000;j += i)
            is_prime[j] = false;
    }
}

void solve(){
    Int a, p;
    scanf("%lld%lld", &a, &p);
    if(!is_prime[p]){
        puts("-1");     
    }
    else if (a % p == 0){
        puts("0");
    }
    else{        
        puts("1");
    }
}

int main(){
    Int t;
    init();
    scanf("%lld", &t);
    while(t--)solve();
    return 0;
}
0