結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー | kyort0n |
提出日時 | 2020-07-31 21:26:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 931 ms / 2,000 ms |
コード長 | 1,006 bytes |
コンパイル時間 | 1,368 ms |
コンパイル使用メモリ | 163,488 KB |
実行使用メモリ | 13,368 KB |
最終ジャッジ日時 | 2023-09-20 21:30:25 |
合計ジャッジ時間 | 11,069 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 911 ms
13,204 KB |
testcase_01 | AC | 891 ms
13,320 KB |
testcase_02 | AC | 895 ms
13,336 KB |
testcase_03 | AC | 732 ms
13,080 KB |
testcase_04 | AC | 582 ms
13,324 KB |
testcase_05 | AC | 882 ms
13,264 KB |
testcase_06 | AC | 846 ms
13,332 KB |
testcase_07 | AC | 931 ms
13,368 KB |
testcase_08 | AC | 95 ms
13,076 KB |
testcase_09 | AC | 94 ms
13,184 KB |
testcase_10 | AC | 95 ms
13,076 KB |
testcase_11 | AC | 96 ms
13,136 KB |
testcase_12 | AC | 97 ms
13,232 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const long long INF = 1e18; //const ll mod = 1000000007; bool IsPrime[10000000]; void solve() { ll A, P; cin >> A >> P; if(!IsPrime[P]) { cout << -1 << endl; return; } if(A % P == 0) cout << 0 << endl; else cout << 1 << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); for(int i = 2; i < 1e7; i++) { IsPrime[i] = true; } for(int i = 2; i < 1e7; i++) { if(!IsPrime[i]) continue; for(int j = i * 2; j < 1e7; j += i) { IsPrime[j] = false; } } ll T; cin >> T; while(T--) solve(); return 0; }