結果
| 問題 |
No.1250 汝は倍数なりや?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-27 20:57:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,129 bytes |
| コンパイル時間 | 3,834 ms |
| コンパイル使用メモリ | 93,680 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-07-21 22:02:48 |
| 合計ジャッジ時間 | 4,040 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 48 |
ソースコード
#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;
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;
}