結果

問題 No.2682 Visible Divisible
ユーザー ゆにぽけ
提出日時 2024-03-20 21:24:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 1,249 ms
コンパイル使用メモリ 122,872 KB
最終ジャッジ日時 2025-02-20 08:40:34
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <random>
#include <utility>
#include <functional>
using namespace std;
template<class T = long long>
T gcd(T a,T b)
{
	while(b)
	{
		a %= b;
		swap(a,b);
	}
	return a;
}

template<class T = long long>
T lcm(T a,T b)
{
	return a / gcd<T>(a,b) * b;
}

void Main()
{
	int N;
	long long K;
	cin >> N >> K;
	long long L = 1;
	for(int i = 0;i < N;i++)
	{
		long long a;
		cin >> a;
		a = gcd(a,K);
		L = lcm(L,a);
	}
	cout << (L == K ? "Yes\n" : "No\n");
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	/* cin >> tt; */
	while(tt--) Main();
}
0