結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-22 11:17:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 567 bytes |
| コンパイル時間 | 2,004 ms |
| コンパイル使用メモリ | 197,832 KB |
| 最終ジャッジ日時 | 2025-01-19 21:01:17 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 39 WA * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int solve() {
int n, m, p;
cin >> n >> m >> p;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a.begin(), a.end());
if (a.back() > m)
return 1;
int y = -1;
for (int i = 0; i < n; i++) {
if (a[i] % p) {
y = max(y, a[i]);
}
}
if (y <= 1)
return -1;
int ret = 0;
long long x = 1;
while (x <= m) {
x *= y;
++ret;
}
return ret;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << solve() << endl;
return 0;
}