結果

問題 No.1218 Something Like a Theorem
ユーザー Atomic67Atomic67
提出日時 2020-09-08 17:09:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,961 bytes
コンパイル時間 1,454 ms
コンパイル使用メモリ 164,892 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 01:23:16
合計ジャッジ時間 2,474 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:82:24: 警告: ‘yv’ may be used uninitialized [-Wmaybe-uninitialized]
   82 |                     yv *= y;
      |                     ~~~^~~~
main.cpp:79:25: 備考: ‘yv’ はここで定義されています
   79 |                 int xv, yv, zv = 1;
      |                         ^~
main.cpp:81:24: 警告: ‘xv’ may be used uninitialized [-Wmaybe-uninitialized]
   81 |                     xv *= x;
      |                     ~~~^~~~
main.cpp:79:21: 備考: ‘xv’ はここで定義されています
   79 |                 int xv, yv, zv = 1;
      |                     ^~

ソースコード

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