結果

問題 No.1556 Power Equality
ユーザー momoyuumomoyuu
提出日時 2024-08-07 20:28:45
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 1,104 ms
コンパイル使用メモリ 102,236 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-07 20:28:48
合計ジャッジ時間 1,928 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;


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

    ll a,b;
    cin>>a>>b;
    auto calc = [](ll a,ll b){
        vector<pair<ll,ll>> res;
        ll now = a;
        for(ll i = 2;i*i<=a;i++) if(now%a==0){
            ll cnt = 0;
            while(now%a==0){
                now /= a;
                cnt++;
            }
            res.push_back(make_pair(i,cnt));
        }
        if(now!=1) res.push_back(make_pair(now,1));
        for(auto&use:res) use.second *= b;
        sort(res.begin(),res.end());
        return res;
    };
    if(calc(a,b)==calc(b,a)) cout<<"Yes\n";
    else cout<<"No\n";
}   

0