結果

問題 No.1556 Power Equality
ユーザー mamimume____momamimume____mo
提出日時 2021-07-26 12:33:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 954 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 172,520 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 07:24:20
合計ジャッジ時間 2,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 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;

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

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

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

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

    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