結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
pyonth
|
| 提出日時 | 2021-01-08 21:36:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,334 bytes |
| コンパイル時間 | 2,017 ms |
| コンパイル使用メモリ | 193,724 KB |
| 最終ジャッジ日時 | 2025-01-17 11:24:42 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr int inf = 1e9 + 10;
constexpr ll INF = (ll)4e18 + 10;
constexpr int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
constexpr int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
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;
}
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int n;
ll m, p;
cin >> n >> m >> p;
ll a[n];
ll mx = 0;
vector<int> cnt(n);
rep(i, n) {
cin >> a[i];
chmax(mx, a[i]);
while (a[i] % p == 0) {
cnt[i]++;
a[i] /= p;
}
}
ll M = 0, C = 0;
rep(i, n) if (chmax(M, a[i])) C = cnt[i];
if (M == 1) {
if (mx > m)
puts("1");
else
puts("-1");
return 0;
}
ll now = 1, ans = 0;
while (now * mx <= m) {
now *= M;
ans += C + 1;
}
cout << ans + 1 << endl;
return 0;
}
pyonth