結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー |
|
提出日時 | 2020-07-31 21:32:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 217 ms / 2,000 ms |
コード長 | 641 bytes |
コンパイル時間 | 1,320 ms |
コンパイル使用メモリ | 165,560 KB |
実行使用メモリ | 17,576 KB |
最終ジャッジ日時 | 2024-07-06 16:43:06 |
合計ジャッジ時間 | 5,244 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h>const int maxp = 1e7 + 3;int p[maxp], pl;bool isc[maxp];int main() {for(int i = 2; i < maxp; ++i) {if(!isc[i])p[pl++] = i;for(int j = 0; j < pl && i * (long long)p[j] < maxp; ++j) {isc[i * p[j]] = true;if(i % p[j] == 0)break;}}isc[0] = isc[1] = true;int t;scanf("%d", &t);while(t--) {long long a; int p;scanf("%lld%d", &a, &p);if(isc[p])puts("-1");else if(a % p != 0)puts("1");elseputs("0");}return 0;}