結果

問題 No.1218 Something Like a Theorem
ユーザー jupiro
提出日時 2020-09-04 22:03:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,813 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 125,128 KB
最終ジャッジ日時 2025-01-14 05:45:18
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0