結果
| 問題 |
No.1250 汝は倍数なりや?
|
| コンテスト | |
| ユーザー |
Fukucchi
|
| 提出日時 | 2020-10-09 22:01:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 5,102 bytes |
| コンパイル時間 | 1,596 ms |
| コンパイル使用メモリ | 134,996 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-07-20 11:20:39 |
| 合計ジャッジ時間 | 4,711 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 TLE * 1 -- * 30 |
コンパイルメッセージ
main.cpp: In function 'void solve(long long int, std::map<long long int, long long int>&)':
main.cpp:173:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
173 | for (const auto &[key, value] : res) {
| ^
main.cpp: In function 'int main()':
main.cpp:196:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
196 | for (const auto &[key, value] : res) {
| ^
ソースコード
#pragma GCC optimize("O3") //コンパイラ最適化用
// #define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm> //sort,二分探索,など
#include <bitset> //固定長bit集合
#include <cassert> //assert(p)で,not pのときにエラー
#include <cctype>
#include <chrono> //実行時間計測
#include <climits>
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional> //sortのgreater
#include <iomanip> //setprecision(浮動小数点の出力の誤差)
#include <ios> // std::left, std::right
#include <iostream> //入出力
#include <iterator> //集合演算(積集合,和集合,差集合など)
#include <map>
#include <numeric> //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>
using namespace std;
typedef long long LL;
typedef long double LD;
#define ALL(x) x.begin(), x.end()
const long long INF = 1e12;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
//略記
#define UMAP unordered_map
#define USET unordered_set
#define FF first
#define SS second
#define int long long
#define LD long double
#define PII pair<int, int>
#define PB push_back
#define MP make_pair
#define SZ(x) (int)((x).size())
#define VI vector<int>
#define VVI vector<vector<int>>
#define VLL vector<LL>
#define VVLL vector<vector<LL>>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n) - (int)1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(b) - (int)1; i >= (int)a; i--)
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int in() {
int x;
cin >> x;
return x;
}
// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << "\n"; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
cout << head;
if (sizeof...(tail) != 0)
cout << " ";
print(forward<Tail>(tail)...);
}
template <class T> void print(vector<T> &vec) {
for (auto &a : vec) {
cout << a;
if (&a != &vec.back())
cout << " ";
}
cout << "\n";
}
template <class T> void print(set<T> &set) {
for (auto &a : set) {
cout << a << " ";
}
cout << "\n";
}
template <class T> void print(vector<vector<T>> &df) {
for (auto &vec : df) {
print(vec);
}
}
long long power(long long x, long long n) {
// O(logn)
// https://algo-logic.info/calc-pow/#toc_id_1_2
long long ret = 1;
while (n > 0) {
if (n & 1)
ret *= x; // n の最下位bitが 1 ならば x^(2^i) をかける
x *= x;
n >>= 1; // n を1bit 左にずらす
}
return ret;
}
long long comb(int n, int k) {
vector<vector<long long>> v(n + 1, vector<long long>(n + 1, 0));
for (int i = 0; i < SZ(v); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int k = 1; k < SZ(v); k++) {
for (int j = 1; j < k; j++) {
v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
}
}
return v[n][k];
}
void add(long long &a, long long b) {
a += b;
if (a >= MOD)
a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
__attribute__((constructor)) void faster_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
// 素因数分解
// https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/prime_factorization.cpp
/*
入力: n は 2 以上の整数
出力: 540 = 2^2 × 3^3 × 5 の場合、({2, 2}, {3, 3}, {5, 1})
*/
map<long long, long long> prime_factorize(long long n) {
map<long long, long long> res;
for (long long p = 2; p * p <= n; ++p) {
while (n % p == 0) {
++res[p];
n /= p;
}
}
if (n != 1)
res[n] = 1;
return res;
}
int n, h;
void solve(int val, map<int, int> &res) {
for (const auto &[key, value] : res) {
while (val % key == 0) {
val /= key;
res[key]--;
}
}
}
signed main() {
cin >> n >> h;
auto res = prime_factorize(h);
VI A(n);
REP(ni, n) { cin >> A[ni]; }
REP(ni, n) {
solve(A[ni], res);
/* print("aha");
for (const auto &[key, value] : res) {
print(key, value);
} */
}
bool ok = true;
for (const auto &[key, value] : res) {
if (value > 0) {
ok = false;
break;
}
}
if (ok) {
print("YES");
} else {
print("NO");
}
return 0;
}
Fukucchi