結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
![]() |
提出日時 | 2020-07-31 21:32:23 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,272 bytes |
コンパイル時間 | 9,740 ms |
コンパイル使用メモリ | 255,564 KB |
最終ジャッジ日時 | 2025-01-12 09:17:53 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 TLE * 5 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}else{puts("No");} /* Max_Prime以下の素数をprimes[]に格納 */ const int Max_Prime = 10000000; int tmp_primes[Max_Prime]; vector<int> primes; void PrimeInit() { rep(i,Max_Prime)tmp_primes[i] = 1; tmp_primes[0] = 0; tmp_primes[1] = 0; rep(i,Max_Prime){ if(tmp_primes[i] == 0)continue; int j = 2; while(i * j < Max_Prime){ tmp_primes[i*j] = 0; j++; } } rep(i,Max_Prime){ if(tmp_primes[i])primes.push_back(i); } } int main() { PrimeInit(); int T; cin >> T; rep(_,T){ ll a, p; cin >> a >> p; auto ite = lower_bound(primes.begin(), primes.end(), p); if(*ite != p){ cout << -1 << endl; continue; }else{ if(a%p==0){ cout << 0 << endl; continue; } cout << 1 << endl; } } return 0; }