讨论 / WA:80 哪位好心人帮忙加个高精度
yx126lrymy 2012-12-21 05:58:00
点我顶贴 收藏 删除
#include <iostream>

#include <cstdio>

using namespace std;

int k,w,s,r;

long long ans=0;

long long f[10001][1<<9];

int main(){

scanf("%d%d",&k,&w);

s=(w-1)/k+1;

for (int i=0;i<=(1<<k)-1;i++)

f[s][i]=1;

for (int i=s-1;i>=2;i--)

for (int j=1;j<=(1<<k)-(s+1-i);j++){

for (int l=j+1;l<=(1<<k)-(s-i);l++)

f[i][j]+=f[i+1][l];

if (!(i==s-1&&j==0)) ans+=f[i][j];

}

r=(w-1)%k+1;

for (int i=1;i<=(1<<r)-1;i++){

for (int j=i+1;j<=(1<<k)-(s-1);j++)

f[1][i]+=f[2][j];

ans+=f[1][i];

}

cout<<ans;

return 0;

}

查看更多回复
提交回复