这题是DP?这DP挺怪。。。反正我想不出。。。

 1 #include<bits/stdc++.h>
 2 #define inc(i,l,r) for(i=l;i<=r;i++)
 3 #define dec(i,l,r) for(i=l;i>=r;i--)
 4 #define mem(a) memset(a,0,sizeof(a))
 5 #define ll long long
 6 #define inf 1e10
 7 #define NM 100+5
 8 #define nm 100000+5
 9 using namespace std;
10 int read(){
11     int x=0,f=1;char ch=getchar();
12     while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
13     while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
14     return f*x;
15 }
16 int n,m,i,j,a[NM],b[NM];
17 ll c[nm];
18 int main(){
19     freopen("humble.in","r",stdin);
20     freopen("humble.out","w",stdout);
21     n=read();m=read();
22     inc(i,1,n)a[i]=read(),b[i]=1;
23     c[1]=1;
24     inc(i,2,m+1){
25         c[i]=inf;
26         inc(j,1,n){
27             while(c[b[j]]*a[j]<=c[i-1])b[j]++;
28             c[i]=min(c[i],c[b[j]]*a[j]);
29         }
30     }
31     printf("%d\n",c[m+1]);
32     return 0;
33 }
View Code

 

posted on 2015-08-22 00:00  onlyRP  阅读(145)  评论(0编辑  收藏  举报