結果

問題 No.1556 Power Equality
コンテスト
ユーザー monnu
提出日時 2021-06-25 22:43:27
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 661 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,537 ms
コンパイル使用メモリ 180,440 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-11 18:46:56
合計ジャッジ時間 1,308 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,pair<int,int>>>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000

int main(){
  ll A,B;
  cin>>A>>B;
  bool flag=true;
  ll a=A;
  ll b=B;
  for(ll i=2;i<=100000;i++){
    ll cnt1=0;
    ll cnt2=0;
    while(a%i==0){
      a/=i;
      cnt1++;
    }
    while(b%i==0){
      b/=i;
      cnt2++;
    }
    if(cnt1*B!=cnt2*A){
      flag=false;
    }
  }
  if(a>1||b>1){
    if(A!=B){
      flag=false;
    }
  }

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