結果

問題 No.1140 EXPotentiaLLL!
ユーザー AngrySadEightAngrySadEight
提出日時 2020-07-31 21:52:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,206 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 1,535 ms
コンパイル使用メモリ 166,264 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 22:57:44
合計ジャッジ時間 13,095 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,192 ms
4,376 KB
testcase_01 AC 1,206 ms
4,376 KB
testcase_02 AC 1,191 ms
4,376 KB
testcase_03 AC 867 ms
4,380 KB
testcase_04 AC 667 ms
4,380 KB
testcase_05 AC 1,043 ms
4,376 KB
testcase_06 AC 997 ms
4,380 KB
testcase_07 AC 1,170 ms
4,376 KB
testcase_08 AC 35 ms
4,380 KB
testcase_09 AC 35 ms
4,376 KB
testcase_10 AC 35 ms
4,376 KB
testcase_11 AC 35 ms
4,380 KB
testcase_12 AC 35 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll T;
    cin >> T;
    vector<bool> isPrime(5000005, true);
    isPrime[1] = false;
    for (ll i = 2; i <= 5000004; i++){
        if (isPrime[i]){
            for (ll j = 2; j * i <= 5000004; j++){
                isPrime[j * i] = false;
            }
        }
    }
    rep(i,T){
        ll A,P;
        cin >> A >> P;
        if (!isPrime[P]) cout << -1 << endl;
        else{
            if (A % P == 0) cout << 0 << endl;
            else cout << 1 << endl;
        }
    }
}
0