結果
問題 | No.1330 Multiply or Divide |
ユーザー |
|
提出日時 | 2021-01-08 23:19:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 810 bytes |
コンパイル時間 | 1,969 ms |
コンパイル使用メモリ | 198,044 KB |
最終ジャッジ日時 | 2025-01-17 14:34:30 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 16 |
ソースコード
/*** author: shu8Cream* created: 08.01.2021 21:06:40**/#include <bits/stdc++.h>using namespace std;#define rep(i,n) for (int i=0; i<(n); i++)#define all(x) (x).begin(), (x).end()using ll = long long;using P = pair<int,int>;using vi = vector<int>;using vvi = vector<vi>;int main() {cin.tie(nullptr);ios::sync_with_stdio(false);int n,m,p;cin >> n >> m >> p;vector<P> a(n);rep(i,n){cin >> a[i].first;while(a[i].first%p==0){a[i].first/=p;a[i].second++;}}sort(all(a));int tmp = 1;int ans = 0;if(a[n-1].first==1){cout << -1 << endl;return 0;}while(tmp<m){tmp*=a[n-1].first;ans+=a[n-1].second+1;}cout << ans-a[n-1].second << endl;}