結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
👑 ![]() |
提出日時 | 2021-01-09 13:48:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 616 bytes |
コンパイル時間 | 2,878 ms |
コンパイル使用メモリ | 191,404 KB |
最終ジャッジ日時 | 2025-01-17 15:37:29 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%llu%llu%llu",&N,&M,&P); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:17:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | ULL a; scanf("%llu",&a); | ~~~~~^~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) ULL N,M,P; ULL maxA; ULL D[70]; ULL dp[150]; int main(){ scanf("%llu%llu%llu",&N,&M,&P); rep(i,70) D[i]=1; maxA=1; rep(i,N){ ULL a; scanf("%llu",&a); int d=1; ULL b=a; while(b%P==0){ b/=P; d++; } D[d]=max(D[d],b); maxA=max(maxA,a); } rep(i,150) dp[i]=1; M=M/maxA; int ans=-1; rep(i,140){ if(dp[i]>M){ ans=i+1; break; } rep(j,70){ if(D[j]==1) continue; if(j==0) continue; dp[i+j]=max(dp[i+j],dp[i]*D[j]); } } printf("%d\n",ans); return 0; }