結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー |
|
提出日時 | 2020-07-31 21:29:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 189 ms / 2,000 ms |
コード長 | 1,052 bytes |
コンパイル時間 | 820 ms |
コンパイル使用メモリ | 88,224 KB |
実行使用メモリ | 9,088 KB |
最終ジャッジ日時 | 2024-07-06 16:28:48 |
合計ジャッジ時間 | 4,348 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include<iostream>#include<cstdio>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>#include<string>#include<queue>#include<stack>#include<complex>using namespace std;#define MOD 1000000007#define MOD2 998244353#define INF (1<<29)#define LINF (1LL<<60)#define EPS (1e-10)#define PI 3.1415926535897932384626433832795028typedef long long Int;typedef pair<Int, Int> P;typedef long double Real;typedef complex<Real> CP;bool is_prime[5500000];void init(){fill(is_prime, is_prime + 5500000, true);is_prime[0] = is_prime[1] = false;for(int i = 2;i*i < 5500000;i++){if(!is_prime[i])continue;for(Int j = i * i;j < 5500000;j += i)is_prime[j] = false;}}void solve(){Int a, p;scanf("%lld%lld", &a, &p);if(!is_prime[p]){puts("-1");}else if (a % p == 0){puts("0");}else{puts("1");}}int main(){Int t;init();scanf("%lld", &t);while(t--)solve();return 0;}