結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
|
提出日時 | 2020-07-31 22:03:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 744 bytes |
コンパイル時間 | 2,253 ms |
コンパイル使用メモリ | 198,356 KB |
最終ジャッジ日時 | 2025-01-12 10:09:11 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 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; }