結果
| 問題 | No.1250 汝は倍数なりや? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-10-27 21:00:54 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,149 bytes | 
| コンパイル時間 | 844 ms | 
| コンパイル使用メモリ | 95,348 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-21 22:02:55 | 
| 合計ジャッジ時間 | 5,775 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 48 TLE * 1 | 
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline, to_string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap, pair
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt,ceil,M_PI, pow, sin
#include <sstream>	//stringstream,getline
#include <numeric>	//gcd, accumlate
#include <deque>	//deque
#include <random>	//randam_device
#include <limits>	//numeric_limits
using namespace std;
constexpr long long int D_MOD = 1000000007;
inline int Greatest_Common_Divisor(int a, int b) {
	//aとbの最大公約数を返す
	while (a != 0 && b != 0) {
		if (a > b) {
			a = a - b;
		}
		else {
			b = b - a;
		}
	}
	return(a + b);
}
int main() {
	int N, H;
	cin >> N >> H;
	int temp = 0;
	int gcd = 0;
	for (int i = 0; i < N; i++) {
		cin >> temp;
		temp = abs(temp);
		if (temp % H == 0) {
			cout << "YES" << endl;
			return 0;
		}
		else {
			gcd = Greatest_Common_Divisor(temp, H);
			H = H / gcd;
		}
		if (H == 1) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}
            
            
            
        