結果

問題 No.1140 EXPotentiaLLL!
ユーザー CleyLCleyL
提出日時 2021-12-01 12:23:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,253 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 63,424 KB
実行使用メモリ 8,508 KB
最終ジャッジ日時 2023-09-17 17:07:32
合計ジャッジ時間 13,802 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,239 ms
8,248 KB
testcase_01 AC 1,253 ms
8,336 KB
testcase_02 AC 1,232 ms
8,224 KB
testcase_03 AC 918 ms
8,224 KB
testcase_04 AC 716 ms
8,208 KB
testcase_05 AC 1,126 ms
8,272 KB
testcase_06 AC 1,080 ms
8,284 KB
testcase_07 AC 1,238 ms
8,264 KB
testcase_08 AC 38 ms
8,256 KB
testcase_09 AC 37 ms
8,244 KB
testcase_10 AC 38 ms
8,248 KB
testcase_11 AC 38 ms
8,284 KB
testcase_12 AC 38 ms
8,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
bool pri[5000001];
void init(){
    pri[0] = pri[1] = true;
    for(int i = 2; 5000001 > i; i++){
        if(!pri[i]){
            for(int j = i+i; 5000001 > j; j+=i){
                pri[j]=true;
            }
        }
    }
}
int main(){
    init();
    int t;cin>>t;
    for(int i = 0; t > i; i++){
        long long a;
        int p;cin>>a>>p;
        if(pri[p]){
            cout << -1 << "\n";
        }else if(!(a%(long long)p)){
            cout << 0 << "\n";
        }else{
            cout << 1 << "\n";
        }
        
    }
}
0