結果

問題 No.1556 Power Equality
ユーザー mamimume____momamimume____mo
提出日時 2021-07-26 12:35:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 171,376 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 07:28:11
合計ジャッジ時間 2,363 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll INFL = 2e18;
template <class T>bool chmin(T &a, T b){ if (a > b) { a = b; return true;} else return false;}
template <class T>bool chmax(T &a, T b){ if (a < b) { a = b; return true;} else return false;}

int main() {
    int A,B;
    cin >> A >> B;

    map<int,ll> mpA;
    map<int,ll> mpB;

    int AA = A;
    for (int i = 2;i * i <= AA;i++) {
        while (AA % i == 0){ 
            AA /= i;
            mpA[i]++;
        }
    }

    if (AA != 1)mpA[AA]++;

    int BB = B;
    for (int i = 2;i * i <= BB;i++) {
        while (BB % i == 0){ 
            BB /= i;
            mpB[i]++;
        }
    }

    if (BB != 1)mpB[BB]++;

    bool flag = true;
    for (auto p:mpA) {
        flag &= (p.second * B == mpB[p.first] * A);
    }
    for (auto p:mpB) {
        flag &= (p.second * A == mpA[p.first] * B);
    }

    if (flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
0