結果

問題 No.1140 EXPotentiaLLL!
コンテスト
ユーザー C
提出日時 2026-11-02 23:57:30
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 88 ms / 2,000 ms
+ 583µs
コード長 1,390 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,042 ms
コンパイル使用メモリ 391,324 KB
実行使用メモリ 9,848 KB
最終ジャッジ日時 2026-11-02 23:57:45
合計ジャッジ時間 10,575 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pll=pair<ll,ll>;
using pi=pair<int,int>;

// using mint=modint998244353;
using mint=modint1000000007;
// using mint2=static_modint<2>;

// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;

// using mint=LazyMontgomeryModInt<998244353>;
using vm=vector<mint>;
// using vvm=vector<vm>;

#line 2 "prime/prime-sieve.hpp"

// Prime -> {0, 0, 1, 1, 0, 1, 0, 1, ...}
vector<bool> prime_sieve(int N) {
  vector<bool> sieve(max(1, N) + 1, 1);
  sieve[0] = sieve[1] = false;
  for (int i = 2; i * i <= N; i++)
    if (sieve[i] == true)
      for (int j = i * i; j <= N; j += i) sieve[j] = false;
  return sieve;
}

int main()
{
  	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	auto is_prime=prime_sieve(5'000'000);

	int T;
	cin>>T;
	while(T--){
		ll A,P;
		cin>>A>>P;
		if(is_prime[P]){
			if(A%P==0)cout<<0<<'\n';
			else cout<<1<<'\n';
		}else{
			cout<<-1<<'\n';
		}
	}
}
0