結果

問題 No.1556 Power Equality
ユーザー ぷら
提出日時 2021-06-29 10:12:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 192,000 KB
最終ジャッジ日時 2025-01-22 14:53:49
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int A,B;
    cin >> A >> B;
    if(A > B) {
        swap(A,B);
    }
    int tmp = B/A;
    int tmp2 = 1;
    if(A == 1 && B != 1) {
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < tmp; i++) {
        tmp2 *= A;
        if(tmp2 > B) {
            break;
        }
    }
    if(tmp2 == B) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
0