結果

問題 No.1140 EXPotentiaLLL!
ユーザー ttkkggwwttkkggww
提出日時 2020-07-31 21:56:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,334 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 1,562 ms
コンパイル使用メモリ 166,708 KB
実行使用メモリ 42,404 KB
最終ジャッジ日時 2023-09-20 23:09:22
合計ジャッジ時間 15,012 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,283 ms
42,172 KB
testcase_01 AC 1,280 ms
42,144 KB
testcase_02 AC 1,305 ms
42,188 KB
testcase_03 AC 1,012 ms
42,128 KB
testcase_04 AC 788 ms
42,192 KB
testcase_05 AC 1,213 ms
42,404 KB
testcase_06 AC 1,139 ms
42,124 KB
testcase_07 AC 1,334 ms
42,304 KB
testcase_08 AC 125 ms
42,116 KB
testcase_09 AC 139 ms
42,148 KB
testcase_10 AC 124 ms
42,124 KB
testcase_11 AC 123 ms
42,256 KB
testcase_12 AC 122 ms
42,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	ll t;
	cin >> t;
	vector<ll> prime(5*1000000+1,1);
	for(ll i = 2;i<5*1000000+1;i++)
	{
		if(prime[i])
		{
			for(ll j = i*2;j<5*1000000+1;j+=i)
			{
				prime[j] = false;
			}
		}
	}
	prime[0] = prime[1] = false;
	while(t--)
	{
		ll a,p;
		cin >> a >> p;
		if(prime[p])
		{
			if(a%p==0)
			{
				cout<<0<<endl;
			}
			else cout << 1 << endl;
		}
		else cout << -1 << endl;
	}
}
0