結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
![]() |
提出日時 | 2021-01-08 22:44:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 774 bytes |
コンパイル時間 | 1,596 ms |
コンパイル使用メモリ | 171,792 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 14:10:30 |
合計ジャッジ時間 | 5,002 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 31 |
ソースコード
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n, m, p; cin >> n >> m >> p; vector<ll> a(n); rep(i, 0, n) cin >> a[i]; sort(a.begin(), a.end()); int cnt = 0; ll mx = 0; int mx_index = -1; rep(i, 0, n){ if(mx < a[i]%p){ mx = a[i]%p; mx_index = i; } } if(a[n-1] > m){ cout << 0 << endl; return 0; } if(mx <= 0){ cout << -1 << endl; return 0; } ll x = 1; while(x <= m){ cnt++; if(x*a[n-1] > m) break; else if(x%p == 0) x /= p; else x *= a[mx_index]; } cout << cnt << endl; return 0; }