結果
| 問題 |
No.1140 EXPotentiaLLL!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-31 22:13:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 220 ms / 2,000 ms |
| コード長 | 746 bytes |
| コンパイル時間 | 2,028 ms |
| コンパイル使用メモリ | 197,968 KB |
| 最終ジャッジ日時 | 2025-01-12 10:26:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:31:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | int p; scanf("%lld%d",&a,&p);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:38:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
38 | int q; scanf("%d",&q); rep(_,q) solve();
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
class Eratosthenes_sieve{
vector<bool> er;
vector<int> p;
public:
Eratosthenes_sieve(int n):er(n+1,true){
if(n>=0) er[0]=false;
if(n>=1) er[1]=false;
for(int i=2;i*i<=n;i++) if(er[i]) for(int j=i*i;j<=n;j+=i) er[j]=false;
rep(i,n+1) if(er[i]) p.emplace_back(i);
}
vector<int> primes()const{ return p; }
bool is_prime(int a)const{
assert(a<=(int)er.size()-1);
return a>=0 && er[a];
}
};
Eratosthenes_sieve E(5e6);
void solve(){
lint a;
int p; scanf("%lld%d",&a,&p);
if(!E.is_prime(p)) puts("-1");
else puts(a%p==0?"0":"1");
}
int main(){
int q; scanf("%d",&q); rep(_,q) solve();
return 0;
}