結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー | hanbei_dayo |
提出日時 | 2020-07-31 22:11:42 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,756 ms / 2,000 ms |
コード長 | 1,123 bytes |
コンパイル時間 | 802 ms |
コンパイル使用メモリ | 96,848 KB |
実行使用メモリ | 8,620 KB |
最終ジャッジ日時 | 2023-09-20 23:42:34 |
合計ジャッジ時間 | 26,077 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,726 ms
8,404 KB |
testcase_01 | AC | 1,723 ms
8,340 KB |
testcase_02 | AC | 1,732 ms
8,304 KB |
testcase_03 | AC | 1,700 ms
8,372 KB |
testcase_04 | AC | 1,670 ms
8,372 KB |
testcase_05 | AC | 1,726 ms
8,276 KB |
testcase_06 | AC | 1,719 ms
8,304 KB |
testcase_07 | AC | 1,756 ms
8,416 KB |
testcase_08 | AC | 1,569 ms
8,440 KB |
testcase_09 | AC | 1,566 ms
8,620 KB |
testcase_10 | AC | 1,567 ms
8,272 KB |
testcase_11 | AC | 1,566 ms
8,400 KB |
testcase_12 | AC | 1,571 ms
8,488 KB |
ソースコード
#include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<string> #include<utility> #include<map> #include<set> #include<queue> #include<stack> #include<functional> #include<math.h> #include<random> #include <bitset> using namespace std; #define N (1000000000+7) //#define N 998244353 #define INF 1e16 typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> Q; const int inf = (int)1e9; ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a%b == 0)return b; else return gcd(b, a%b); } bool prime[5000010]; void furui() { prime[0]=true; prime[1]=true; int i = 2; while (i <= 5000000) { int j = 2; while (j*j <= i && !prime[i]) { if (i%j == 0) { prime[i] = true; break; } else j++; } int z = 2; while (!prime[i]) { if (i*z <= 5000000) { prime[i*z] = true; z++; } else break; } i++; } } int main(void){ int T; scanf("%d",&T); furui(); for(int i=0;i<T;i++){ ll a,p; scanf("%ld%ld",&a,&p); if(prime[p])printf("-1\n"); else{ if(a%p==0)printf("0\n"); else printf("1\n"); } } return 0; }