結果

問題 No.1250 汝は倍数なりや?
ユーザー chacoder1
提出日時 2020-11-25 22:56:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 2,250 ms
コンパイル使用メモリ 199,424 KB
最終ジャッジ日時 2025-01-16 05:43:03
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 1 TLE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  int N,H;
  cin>>N>>H;
  int temp;
  map<int,int>mp;
  map<int,int>np;
  
  for(int i=0;i<N;i++){
    cin>>temp;
    if(temp==1) continue;
    if(temp<0) temp*=-1;
    if(temp==0) continue;
    for(int j=2;j*j<temp;j++){
      if(temp%j==0){
        mp[j]++;
        temp/=j;
        j--;
      }
    }
    mp[temp]++;
  }
  temp=H;
  for(int i=2;i<=H;i++){
    if(temp%i==0){
      np[i]++;
      temp/=i;
      i--;
    }
  }
  for(auto itr=np.begin();itr !=np.end();itr++){
    if(mp[(itr->first)]<itr->second){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;

  return 0;
}


 
0