結果

問題 No.2682 Visible Divisible
ユーザー ゆにぽけゆにぽけ
提出日時 2024-03-20 21:24:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 1,197 ms
コンパイル使用メモリ 125,972 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-20 21:24:15
合計ジャッジ時間 4,703 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
6,676 KB
testcase_01 AC 147 ms
6,676 KB
testcase_02 AC 152 ms
6,676 KB
testcase_03 AC 149 ms
6,676 KB
testcase_04 AC 153 ms
6,676 KB
testcase_05 AC 150 ms
6,676 KB
testcase_06 AC 144 ms
6,676 KB
testcase_07 AC 149 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 152 ms
6,676 KB
testcase_12 AC 153 ms
6,676 KB
testcase_13 AC 145 ms
6,676 KB
testcase_14 AC 154 ms
6,676 KB
testcase_15 AC 146 ms
6,676 KB
testcase_16 AC 145 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

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