結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
![]() |
提出日時 | 2024-01-06 00:39:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 201 ms / 2,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 2,120 ms |
コンパイル使用メモリ | 197,708 KB |
最終ジャッジ日時 | 2025-02-18 16:20:27 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;vector<bool> prime;//O(NloglogN)void erat(ll N){prime.resize(N+1, 1);prime[0] = 0;prime[1] = 0;for (ll i=2; i*i<=N; i++){if (prime[i]){for (ll j=i*2; j <= N; j+=i){prime[j] = 0;}}}}int main(){cin.tie(nullptr);ios_base::sync_with_stdio(false);erat(5000000);ll T, A, N;cin >> T;while(T){T--;cin >> A >> N;if (prime[N]){cout << (A % N == 0 ? 0 : 1) << '\n';}else cout << -1 << '\n';}return 0;}