結果

問題 No.1140 EXPotentiaLLL!
ユーザー takumattakumat
提出日時 2020-07-31 21:38:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,479 bytes
コンパイル時間 978 ms
コンパイル使用メモリ 87,972 KB
実行使用メモリ 100,100 KB
最終ジャッジ日時 2023-09-20 22:11:17
合計ジャッジ時間 8,077 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}
template <class _T> static _T tp_modfact(_T n, _T k, _T mod = (_T)1) {
	_T count = 0;
	_T ans = 1;

	while (count < k) {
		ans = ans * (n - count) % mod;
		count++;
	}
	return ans;
}
template <class _T> void tp_getPrimes(_T targ, std::map<_T, _T>& primes)
{
	_T target = targ;
	_T i = 2;
	while ((i * i) <= target) {
		if ((target % i) == 0) {
			target /= i;
			primes[i]++;
		}
		else {
			i++;
		}
	}
	if (target > 1) {
		primes[target]++;
	}
}

static void exec()
{
	int T;
	get(T);

	while (T--) {
		LLONG A, P;
		get(A, P);
		std::map<LLONG, LLONG> prime;
		tp_getPrimes<LLONG>(P, prime);

		LLONG ans = -1;
		if (prime.size() == 1 && prime.begin()->second == 1) {
			ans = 1;
		}
		printf("%lld\n", ans);
	}
}
0