結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
![]() |
提出日時 | 2021-01-08 21:45:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 696 bytes |
コンパイル時間 | 1,323 ms |
コンパイル使用メモリ | 163,444 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 11:00:41 |
合計ジャッジ時間 | 4,420 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 WA * 10 |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2021.01.08 21:45:08 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n,m,p;cin >> n >> m >> p; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; if (p == 1) continue; while (a[i] % p == 0) { a[i] /= p; } } sort(a.rbegin(), a.rend()); int ans = 0; ll x = 1; if (x >= m) { cout << 0 << endl; return 0; } if (p == 1 || a[0] == 1) { cout << -1 << endl; return 0; } while(x < m) { x *= a[0]; ans++; } cout << ans << endl; return 0; }