結果

問題 No.1140 EXPotentiaLLL!
ユーザー forest3forest3
提出日時 2020-08-04 21:32:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,156 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 1,769 ms
コンパイル使用メモリ 166,260 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-12 22:48:50
合計ジャッジ時間 13,490 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,148 ms
4,352 KB
testcase_01 AC 1,140 ms
4,372 KB
testcase_02 AC 1,156 ms
4,372 KB
testcase_03 AC 836 ms
4,368 KB
testcase_04 AC 633 ms
4,368 KB
testcase_05 AC 987 ms
4,376 KB
testcase_06 AC 965 ms
4,372 KB
testcase_07 AC 1,127 ms
4,372 KB
testcase_08 AC 20 ms
4,368 KB
testcase_09 AC 20 ms
4,368 KB
testcase_10 AC 19 ms
4,372 KB
testcase_11 AC 20 ms
4,368 KB
testcase_12 AC 20 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
	int T;
	cin >> T;

	int N = 5000000;
	vector<bool> prime( N + 1, true );
	prime[0] = false;
	prime[1] = false;
	for( int i = 2; i * i <= N; i++ ) {
		if( prime[ i ] ) {
			for( int j = 2; i * j <= N; j++ ) {
				prime[ i * j ] = false;
			}
		}
	}

	for( int i = 0; i < T; i++ ) {
		long long A, P;
		cin >> A >> P;
		if( prime[P] == false ) cout << -1 << endl;
		else {
			int ans = 0;
			if( A % P ) ans = 1;
			cout << ans << endl;
		}
	}
}
0