結果
問題 | No.1218 Something Like a Theorem |
ユーザー |
|
提出日時 | 2020-09-04 21:49:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 1,822 bytes |
コンパイル時間 | 1,897 ms |
コンパイル使用メモリ | 196,096 KB |
最終ジャッジ日時 | 2025-01-14 05:31:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h>using namespace std;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;}#define DEBUG#ifdef DEBUGvoid debug_out() { cerr << endl; }template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << H;debug_out(T...);}#define debug(...) \cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl#else#define debug(...) (void(0))#define dump(x) (void(0))#endifstruct Setup {Setup() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}} __Setup;using ll = long long;#define ALL(v) (v).begin(), (v).end()#define RALL(v) (v).rbegin(), (v).rend()const double EPS = 1e-7;const int INF = 1 << 30;const ll LLINF = 1LL << 60;constexpr int MOD = 1000000007;const int dx[4] = {1, 0, -1, 0};const int dy[4] = {0, 1, 0, -1};//-------------------------------------int power(int n, int k) {if(k == 0) {return 1;}if(k & 1) {return n * power(n, k - 1);} else {int t = power(n, (k >> 1));return t * t;}}int main() {int n, z;cin >> n >> z;int zn = power(z, n);for(int x = 1; x < z; x++) {for(int y = 1; y < z; y++) {int tmp = power(x, n) + power(y, n);if(tmp > zn) {break;} else if(tmp == zn) {cout << "Yes\n";return 0;}}}cout << "No\n";}