結果
| 問題 |
No.1140 EXPotentiaLLL!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-31 23:17:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,429 bytes |
| コンパイル時間 | 2,353 ms |
| コンパイル使用メモリ | 198,224 KB |
| 最終ジャッジ日時 | 2025-01-12 11:38:44 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for(ll i = 2; i <= n; ++i) {
if(f[i]) continue;
primes.push_back(i);
f[i] = i;
for(ll j = i * i; j <= n; j += i) {
if(!f[j]) f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while(x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if(fl.size() == 0) return {};
vector<P> res(1, P(fl[0], 0));
for(int p : fl) {
if(res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
int main() {
ll t;
cin >> t;
Sieve si(6000000);
rep(_, t) {
ll a, p;
cin >> a >> p;
if(si.isPrime(p))
cout << 1 << '\n';
else
cout << -1 << '\n';
}
}