結果

問題 No.1218 Something Like a Theorem
ユーザー Atomic67Atomic67
提出日時 2020-09-08 17:17:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,020 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 168,440 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-07 09:05:03
合計ジャッジ時間 2,369 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
    }
};

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;
        }
    }
    if(n == 2) {
        for(int x = 1; x <= 1e3; ++x) {
            for(int y = 1; y <= 1e3; ++y) {
                if(x*x + y*y == z * z) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
        cout <<"No" << endl;
        return 0;
    }
    if(n >= 3) {
        for(int x = 1; x <= 1e2; ++x) {
            for(int y = 1; y <= 1e2; ++y) {
                int xv = 1;
                int yv = 1;
                ll zv = 1;
                rep(i, n) {
                    xv *= x;
                    yv *= y;
                    zv *= ll(z);
                }
                if(ll(xv) + ll(yv) == zv) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
        cout << "No" << endl;
        return 0;
    }
    return 0;
}
0