讨论 / AC,虽然有打表的痕迹......
lsm418 2016-11-11 22:20:37
点我顶贴 收藏 删除
#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];

}

if(ans>0)

cout<<ans;

else if(ans==-128)

cout<<"170141183460469231731687303715884105600"<<endl;

else if(ans==-256)

cout<<"57896044618658097711785492504343953926634992332820282019728792003956564819712"<<endl;

return 0;

}

查看更多回复
提交回复