hdu4906 Our happy ending,hdu4906ending
給一個n個數的數列,從中取一些數構成新數列,
如果新數列中有一些數的和是k,那麼這就是一個好數列,問這樣的數列的個數。
從1~n位枚舉其取值從1~min(l,k),來更新可達狀態。
dp[i]中i的二進位每一位表示和(1~k),1表示可以取到,0表示取不到。
#include <iostream>#include <cstring>#include <string>#include <cstdio>#include <cmath>#include <algorithm>#include <vector>#include <queue>#include <map>#define inf 0x3f3f3f3f#define eps 1e-6#define ll long longconst ll mod=1e9+7;const int maxn=(1<<21);using namespace std;ll dp[maxn],ans,v;int n,k,l,d,s;int main(){ int icy,i,j,p,next; scanf("%d",&icy); while(icy--) { scanf("%d%d%d",&n,&k,&l); d=abs(l-k); l=min(l,k); s=(1<<k)-1; memset(dp,0,sizeof dp); dp[0]=1; for(i=0;i<n;i++) { for(j=s;j>=0;j--) { v=dp[j]; if(v==0) continue; for(p=1;p<=l;p++) { next=(1<<(p-1))|j|((j<<p)&s);//加上p本身這個數 以及 其餘所有1的位加上p之後的數 即組成了所有加上p之後的情況 dp[next]=(dp[next]+v)%mod; } dp[j]+=(v*d%mod);//另外此位還可以取不在[1,k]範圍內的數,乘起來就行了 dp[j]%=mod; } } ans=0; for(i=0;i<=s;i++) { if(i&(1<<(k-1))) { ans+=dp[i]; ans%=mod; } } cout<<ans<<endl; } return 0;}
mika的happy ending歌詞
歌曲:Happy Ending 演唱者:Mika
This is the way you left me, I'm not pretending
No hope, no love, no glory, no happy ending
This is the way that we love, like its forever
Then live the rest of our life but not together
Wake up in the morning, stumble on my life
Can't get no love without sacrifice
If anything should happen, I guess I wish you well
Mmm a little bit of heaven with a little bit of hell
This is the hardest story that I've ever told (ooohh)
No hope, no love, no glory
A happy ending gone forever more
I feel as if I'm wasted
And I'm wasted everyday
This is the way you left me, I'm not pretending
No hope, no love, no glory, no happy ending
This is the way that we love, like its forever
Then live the rest of our life but not together
Two o'clock in the morning, something's on my mind
Can't get no rest, keep walking around
If I pretend that nothing ever went wrong
I can get to my sleep, I can think that we just carried on
This is the hardest story that I've ever told (ooohh)
No hope, no love, no glory
A happy ending gone forever more
I feel as if I'm wasted
And I'm wasted everyday
This is the way you left me (oh I feel as if I'm wasted) I'm not pretending
No hope, no love, no glory, no happy ending
This is the way that we love (and I'm wasted everyday) like its forever
Then live the rest of our life but not together
Little bit of love
Little bit of love [repeat匽
I feel as if I......餘下全文>>
happy ending 什意思
快樂的結局