結果
| 問題 |
No.1140 EXPotentiaLLL!
|
| コンテスト | |
| ユーザー |
yakki
|
| 提出日時 | 2020-07-31 21:50:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,472 bytes |
| コンパイル時間 | 1,203 ms |
| コンパイル使用メモリ | 119,916 KB |
| 最終ジャッジ日時 | 2025-01-12 09:50:16 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 6 |
ソースコード
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
const double EPS = 1e-10;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
std::vector<bool> IsPrime;
void sieve(size_t max){
if(max+1 > IsPrime.size()){ // resizeで要素数が減らないように
IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
}
IsPrime[0] = false; // 0は素数ではない
IsPrime[1] = false; // 1は素数ではない
for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
if(IsPrime[i]) // iが素数ならば
for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
IsPrime[i*j] = false; // 素数ではない
}
int main(){
int t; cin >> t;
sieve(5000005);
while(t--){
ll a; cin >> a;
int p; cin >> p;
if(!IsPrime[p]) cout << -1 << endl;
else{
if(a == p) cout << 0 << endl;
else cout << 1 << endl;
}
}
}
yakki