結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
![]() |
提出日時 | 2021-01-08 21:29:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 624 bytes |
コンパイル時間 | 1,843 ms |
コンパイル使用メモリ | 198,912 KB |
最終ジャッジ日時 | 2025-01-17 11:16:52 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 WA * 7 |
ソースコード
#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = (1LL << 61); ll mod = (ll)1e9 + 7; signed main() { ll N, M, P; cin >> N >> M >> P; vector<ll>A(N); for (int i = 0; i < N; i++)cin >> A[i]; sort(A.rbegin(), A.rend()); ll ans = INF; for (int i = 0; i < N; i++) { if (A[i] > M) { ans = min(ans, 1LL); } if (A[i] % P != 0) { ll x = 1; ll now = 0; while (true) { if (x > M)break; now++; if(now != 0)x *= A[i]; else x *= A[0]; } ans = min(ans, now); } } if (ans != INF)cout << ans << endl; else cout << -1 << endl; }