結果
| 問題 | No.1330 Multiply or Divide |
| コンテスト | |
| ユーザー |
👑 Nachia
|
| 提出日時 | 2021-01-09 13:48:38 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 616 bytes |
| 記録 | |
| コンパイル時間 | 1,199 ms |
| コンパイル使用メモリ | 209,648 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-16 14:24:09 |
| 合計ジャッジ時間 | 3,224 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 WA * 1 |
ソースコード
#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;
}
Nachia