結果
| 問題 |
No.1218 Something Like a Theorem
|
| コンテスト | |
| ユーザー |
Atomic67
|
| 提出日時 | 2020-09-08 17:30:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,551 bytes |
| コンパイル時間 | 1,596 ms |
| コンパイル使用メモリ | 166,904 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-30 01:00:35 |
| 合計ジャッジ時間 | 2,437 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmin(T& a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
struct Unionfind {
vector<int> par;
Unionfind(int n) : par(n) {
for(int i = 0; i < n; ++i) par[i] = i;
}
int root(int x) {
if(par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if(rx == ry) return;
par[rx] =ry;
}
bool same(int x, int y) {
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
ll f(int x, int n) {
if(n == 1) return x;
return ll(x)*f(x, n-1);
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n, z;
cin >> n >> z;
if(n == 1) {
if(z != 1) {
cout << "Yes" << endl;
return 0;
}
else {
cout << "No" << endl;
return 0;
}
}
else {
for(int x = 1; x <= z; ++x) {
for(int y = 1; y <= z; ++y) {
if(f(x, n) + f(y, n) == f(z, n)) {
cout << "Yes" << endl;
return 0;
}
}
}
cout << "No" << endl;
return 0;
}
}
Atomic67