結果

問題 No.1218 Something Like a Theorem
ユーザー Mister
提出日時 2020-09-04 21:27:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 301 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 74,988 KB
最終ジャッジ日時 2025-01-14 05:01:26
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>

int pow(int x, int n) {
    int ret = 1;
    while (n--) ret *= x;
    return ret;
}

void solve() {
    int n, z;
    std::cin >> n >> z;

    std::set<int> s;
    for (int x = 1; x <= z; ++x) s.insert(pow(x, n));

    for (auto x : s) {
        if (s.count(pow(z, n) - x)) {
            std::cout << "Yes\n";
            return;
        }
    }

    std::cout << "No\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0