結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
![]() |
提出日時 | 2020-10-30 16:35:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 761 bytes |
コンパイル時間 | 2,047 ms |
コンパイル使用メモリ | 196,080 KB |
最終ジャッジ日時 | 2025-01-15 16:32:07 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 46 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d %d %d", &n, &m, &p); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:21:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | REP(i, n) { scanf("%d", &a[i]); } | ~~~~~^~~~~~~~~~~~~
ソースコード
#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++) template <class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } int main() { int n, m, p; scanf("%d %d %d", &n, &m, &p); vector a(n, 0), b(50, 0); REP(i, n) { scanf("%d", &a[i]); } int maxa = *max_element(a.begin(), a.end()); REP(i, n) { int cnt = 1, copy = a[i]; while(copy % p == 0) copy /= p, cnt++; chmax(b[cnt], a[i]); } vector achive(3100, 1ll); REP(i, 3000) { REP(j, 50) { if(achive[i] <= m) chmax(achive[i + j], achive[i] * b[j]); } } REP(i, 3100) { if(achive[i] * maxa > m) { printf("%d\n", i); return 0; } } puts("-1"); }