結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー | ryoissy |
提出日時 | 2020-07-31 21:35:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 234 ms / 2,000 ms |
コード長 | 573 bytes |
コンパイル時間 | 1,538 ms |
コンパイル使用メモリ | 164,540 KB |
実行使用メモリ | 10,344 KB |
最終ジャッジ日時 | 2023-09-20 22:05:27 |
合計ジャッジ時間 | 5,592 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 201 ms
10,184 KB |
testcase_01 | AC | 197 ms
10,188 KB |
testcase_02 | AC | 204 ms
10,252 KB |
testcase_03 | AC | 180 ms
10,308 KB |
testcase_04 | AC | 143 ms
10,240 KB |
testcase_05 | AC | 203 ms
10,252 KB |
testcase_06 | AC | 197 ms
10,296 KB |
testcase_07 | AC | 234 ms
10,180 KB |
testcase_08 | AC | 40 ms
10,344 KB |
testcase_09 | AC | 39 ms
10,232 KB |
testcase_10 | AC | 41 ms
10,264 KB |
testcase_11 | AC | 41 ms
10,236 KB |
testcase_12 | AC | 41 ms
10,228 KB |
ソースコード
#include <bits/stdc++.h> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int,int> P; int t; bool prime[5000005]; ll fact[500005]; void solve(){ ll a,p; scanf("%lld%lld",&a,&p); if(!prime[p]){ printf("-1\n"); }else if(a%p!=0LL){ printf("1\n"); }else{ printf("0\n"); } } int main(void){ memset(prime,true,sizeof(prime)); prime[0]=prime[1]=false; for(ll i=2;i<=5000000;i++){ if(prime[i]){ for(int j=i*2;j<=5000000;j+=i){ prime[j]=false; } } } scanf("%d",&t); for(int i=0;i<t;i++){ solve(); } return 0; }