結果
問題 | No.1330 Multiply or Divide |
ユーザー |
|
提出日時 | 2023-01-28 01:18:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 951 bytes |
コンパイル時間 | 1,640 ms |
コンパイル使用メモリ | 194,400 KB |
最終ジャッジ日時 | 2025-02-10 07:26:51 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 WA * 8 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define fi first#define se second#define pb push_backusing vi = vector <int>;using ll = long long;using vl = vector <ll>;using pii = pair <int, int>;//~ const ll mod = 998244353;const ll mod = 1e9 + 7;ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a;for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; }const int N = 2e5 + 11;int a[N], b[N];int main() {ios :: sync_with_stdio(false);int n, m, p; cin >> n >> m >> p;for(int i = 0; i < n; i ++) {cin >> a[i];b[i] = a[i];while(a[i] % p == 0)a[i] /= p;}int x = *max_element(a, a + n);int y = *max_element(b, b + n); // last onlyif(m == 1)cout << "0\n";else if(x == 1) {if(y > m)cout << "1\n";elsecout << "-1\n";} else {ll t = 1, c = 0;while(t <= m) {if(t * y > m) {c ++;break;} else {t *= x;c ++;}}cout << c << '\n';}}