結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー | Haar |
提出日時 | 2020-07-31 21:45:16 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 216 ms / 2,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 2,009 ms |
コンパイル使用メモリ | 199,424 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-20 22:41:07 |
合計ジャッジ時間 | 5,532 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 204 ms
4,380 KB |
testcase_01 | AC | 201 ms
4,380 KB |
testcase_02 | AC | 216 ms
4,380 KB |
testcase_03 | AC | 147 ms
4,380 KB |
testcase_04 | AC | 120 ms
4,376 KB |
testcase_05 | AC | 170 ms
4,380 KB |
testcase_06 | AC | 164 ms
4,380 KB |
testcase_07 | AC | 204 ms
4,380 KB |
testcase_08 | AC | 32 ms
4,376 KB |
testcase_09 | AC | 33 ms
4,380 KB |
testcase_10 | AC | 33 ms
4,376 KB |
testcase_11 | AC | 33 ms
4,376 KB |
testcase_12 | AC | 33 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> /** * @title Sieve of Eratosthenes * @docs eratosthenes_sieve.md */ template <int MAX> struct EratosthenesSieve{ static std::bitset<MAX+1> is_prime; static void init(){ is_prime.flip(); is_prime[0] = is_prime[1] = false; for(int i = 2; i <= MAX; ++i){ if(is_prime[i]){ for(int j = 2*i; j <= MAX; j += i){ is_prime[j] = false; } } } } }; template <int MAX> std::bitset<MAX+1> EratosthenesSieve<MAX>::is_prime; using E = EratosthenesSieve<5000000>; int main(){ E::init(); std::cin.tie(0); std::ios::sync_with_stdio(false); int T; std::cin >> T; while(T--){ int64_t A, P; std::cin >> A >> P; if(E::is_prime[P]){ if(A % P == 0){ std::cout << 0 << "\n"; }else{ std::cout << 1 << "\n"; } }else{ std::cout << -1 << "\n"; } } return 0; }