結果

問題 No.1218 Something Like a Theorem
コンテスト
ユーザー akoba
提出日時 2021-01-29 16:33:50
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 740 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 517 ms
コンパイル使用メモリ 80,972 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-14 08:19:06
合計ジャッジ時間 1,556 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <string>
#include <math.h>

using namespace std;
using INT = unsigned long long;

INT _pow(INT a, INT b)
{
    INT c = a;
    while (--b > 0) {
        c *= a;
    }
    return c;
}

const char *solve(INT n, INT z)
{
    const INT A = pow(z, n);
    INT x, y;

    x = 1;
    while (1) {
        y = 1;
        while (1) {
            INT a = _pow(x, n) + _pow(y, n);
            if (a == A) {
                return "Yes";
            }
            if (a > A) {
                if (y == 1) {
                    return "No";
                }
                break;
            }
            y++;
        }
        x++;
    }
}

int main()
{
    INT n, z;
    cin >> n >> z;
    cout << solve(n, z) << endl;
}
0