結果

問題 No.1250 汝は倍数なりや?
ユーザー KKT89
提出日時 2020-10-09 21:33:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 68 ms / 1,000 ms
コード長 659 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 198,412 KB
最終ジャッジ日時 2025-01-15 04:06:42
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,h; cin >> n >> h;
	vector<pair<int,int>> f;
	for(int i=2;i*i<=h;i++){
		if(h%i==0){
			int cnt=0;
			while(h%i==0){
				h/=i;
				cnt++;
			}
			f.push_back({i,cnt});
		}
	}
	if(h>1)f.push_back({h,1});
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	bool ok=true;
	for(int i=0;i<f.size();i++){
		int cnt=0;
		for(int j=0;j<n;j++){
			while(a[j]%f[i].first==0 and cnt<f[i].second){
				a[j]/=f[i].first;
				cnt++;
			}
		}
		if(cnt<f[i].second)ok=false;
	}
	if(ok)printf("YES\n");
	else printf("NO\n");
}
0