結果

問題 No.1218 Something Like a Theorem
ユーザー 👑 jupirojupiro
提出日時 2020-09-04 22:03:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,813 bytes
コンパイル時間 1,301 ms
コンパイル使用メモリ 127,708 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-17 15:40:34
合計ジャッジ時間 2,017 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

ll power(ll x, ll n) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return power(x * x, n / 2);
	}
	else {
		return x * power(x, n - 1);
	}
}
ll nsq(ll X, int n) {
	ll t = pow(X, 1.0 / (double)n);
	ll res = -1;
	for (ll i = max(0LL, t - 5); i <= t + 5; i++) if (power(t, n) <= X) res = t;
	return res;
}
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n, z; cin >> n >> z;
	if (n >= 3) {
		cout << "No" << endl;
	}
	else {
		ll zn = 1; for (int i = 0; i < n; i++) zn *= z;
		for (ll x = 1;; x++) {
			if (power(x, n) >= zn) {
				cout << "No" << endl;
				return 0;
			}
			ll yn = zn - power(x, n);
			ll y = nsq(yn, n);
			if (y > 0 and power(y, n) == yn) {
				cout << "Yes" << "\n";
				return 0;
			}
		}
	}
	return 0;
}
0