結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー |
|
提出日時 | 2020-07-31 21:38:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 231 ms / 2,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 1,566 ms |
コンパイル使用メモリ | 167,256 KB |
実行使用メモリ | 22,784 KB |
最終ジャッジ日時 | 2024-07-06 16:58:15 |
合計ジャッジ時間 | 5,135 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;constexpr char newl = '\n';template<typename T>vector<int> sieve(T n) {vector<int> is_prime(n + 1, true);is_prime[0] = false;is_prime[1] = false;for (T i = 2; i <= n; i++) {if (!is_prime[i]) continue;// res.emplace_back(i);for (T j = 2 * i; j <= n; j += i) is_prime[j] = false;}return is_prime;}int main() {cin.tie(nullptr);ios::sync_with_stdio(false);auto isp = sieve(5000000);int t;cin >> t;for (int i = 0; i < t; i++) {ll a;int p;cin >> a >> p;cout << (isp[p] ? (a % p != 0) : -1) << newl;}return 0;}