結果

問題 No.1140 EXPotentiaLLL!
ユーザー face4face4
提出日時 2020-08-07 09:20:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 63,556 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-10-24 00:33:11
合計ジャッジ時間 4,863 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 226 ms
8,704 KB
testcase_01 AC 223 ms
8,704 KB
testcase_02 AC 227 ms
8,704 KB
testcase_03 AC 178 ms
8,704 KB
testcase_04 AC 142 ms
8,704 KB
testcase_05 AC 206 ms
8,704 KB
testcase_06 AC 197 ms
8,704 KB
testcase_07 AC 234 ms
8,704 KB
testcase_08 AC 37 ms
8,704 KB
testcase_09 AC 36 ms
8,704 KB
testcase_10 AC 36 ms
8,704 KB
testcase_11 AC 37 ms
8,704 KB
testcase_12 AC 37 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

typedef long long ll;
bool nonp[5000001] = {};

int main(){
    nonp[1] = true;
    for(int i = 2; i < 5000001; i++){
        if(nonp[i]) continue;
        for(int j = i+i; j < 5000001; j += i){
            nonp[j] = true;
        }
    }
    int t;
    scanf("%d", &t);
    ll a;
    int p;
    while(t-- > 0){
        scanf("%lld %d", &a, &p);
        printf("%d\n", nonp[p] ? -1 : a%p==0 ? 0 : 1);
    }
    return 0;
}

0