結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
![]() |
提出日時 | 2020-10-30 16:15:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 727 bytes |
コンパイル時間 | 3,320 ms |
コンパイル使用メモリ | 203,132 KB |
最終ジャッジ日時 | 2025-01-15 16:31:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 WA * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:40:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=] 40 | printf("%d\n", res + 1); | ~^ ~~~~~~~ | | | | int ll {aka long long int} | %lld
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define REP(i, x) for(int i = 0; i < (x); i++) ll res, x = 1; int main() { int n, m, p; cin >> n >> m >> p; vector a(n, 0); REP(i, n) { cin >> a[i]; } int amax = *max_element(a.begin(), a.end()); vector<pii> b(n); REP(i, n) { int num = 1; while(a[i] % p == 0) a[i] /= p, num++; b[i] = pii(a[i], num); } auto f = [](pii a, pii b) { return a.first / (double)a.second < b.first / (double)b.second; }; sort(b.rbegin(), b.rend(), f); if(amax <= m and b[0].first == 1) { puts("-1"); return 0; } int lim = m / amax + 1; while(x < lim) x *= b[0].first, res += b[0].second; printf("%d\n", res + 1); }