結果

問題 No.1140 EXPotentiaLLL!
ユーザー firiexpfiriexp
提出日時 2020-07-31 21:29:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,048 bytes
コンパイル時間 1,089 ms
コンパイル使用メモリ 108,180 KB
実行使用メモリ 5,800 KB
最終ジャッジ日時 2023-09-20 21:42:20
合計ジャッジ時間 12,566 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,230 ms
5,796 KB
testcase_01 AC 1,194 ms
5,464 KB
testcase_02 WA -
testcase_03 AC 874 ms
5,712 KB
testcase_04 AC 686 ms
5,664 KB
testcase_05 AC 1,047 ms
5,668 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 50 ms
5,484 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 50 ms
5,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<bool> is_prime;
vector<int> get_prime(int n){
    if(n <= 1) return vector<int>();
    is_prime.resize(n+1, true);

    vector<int> prime;
    is_prime[0] = is_prime[1] = 0;
    for (int i = 2; i <= n; ++i) {
        if(is_prime[i]) prime.emplace_back(i);
        for (auto &&j : prime){
            if(i*j > n) break;
            is_prime[i*j] = false;
            if(i % j == 0) break;
        }
    }
    return prime;
}
auto v = get_prime(5000001);
void solve(){
    ll a, p;
    cin >> a >> p;
    if(is_prime[p]) {
        puts(p == 1 ? "0" : "1");
    }else puts("-1");
}


int main() {
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
0