HDU 3985 Harry Potter and the D.A.
来源:互联网 发布:数据预处理的基本原理 编辑:程序博客网 时间:2024/06/06 00:46
显然题目需要求
将
上述做法是
(八成不是正解
#include<algorithm>#include<iostream>#include<cstring>#include<cstdio>using namespace std;//--Container--//typedef long long ll;#define clr(a) memset(a,0,sizeof(a))const ll md=1000000007;int n,k,ct=0,sd[101][2],sds[101][101],sn;ll cb[110][110],fb[110],fbs[110],dcs[110][110],dp[101][102][1<<9];ll qni(ll a,ll b){ll r=1;for(;b;b>>=1,a=a*a%md)if(b&1)r=r*a%md;return r;};void init(){ int i,j;for(clr(cb),i=0;i<=100;++i)for(cb[i][0]=1,j=1;j<=i;++j) cb[i][j]=(cb[i-1][j-1]+cb[i-1][j])%md; for(fb[0]=1,i=1;i<=100;++i)fb[i]=fb[i-1]*(ll)i%md; for(i=1;i<=100;++i)fbs[i]=qni(fb[i],md-2); for(i=0;i<=100;++i){ dcs[i][1]=fb[i];for(j=2;j<=100;++j)dcs[i][j]=dcs[i][j-1]*fb[i]%md; }};void _qs(int n){ int i,j,d=sqrt((double)n);for(sn=0,i=2;n>1&&i<=d;++i)if(!(n%i)){ sd[sn][0]=i,sd[sn][1]=0;for(;!(n%i);n/=i,++sd[sn][1]);++sn; } if(n>1){sd[sn][0]=n,sd[sn][1]=1;++sn;}};void cl(){ int i,j,t,d,z,q,p,e;scanf("%d %d",&n,&k);if(k==1){printf("Case %d: 1\n",++ct);return;}sn=0;_qs(k); for(clr(sds),i=1;i<=n;++i)if(!(k%i)){ for(t=i,j=0;j<sn;++j){sds[i][j]=0;for(;!(t%sd[j][0]);t/=sd[j][0],++sds[i][j]);} } for(clr(dp),dp[n][n+1][0]=1,i=n;i;--i)for(j=n+1;j;--j)for(t=0;t<(1<<sn);++t)if(dp[i][j][t]){ for(d=j-1;d;--d)if(!(k%d)&&i>=d){ int nx=t;ll tx;for(z=0;z<sn;++z)if(sds[d][z]==sd[z][1])nx|=(1<<z); for(q=1,e=d,tx=1;d*q<=i;++q){ ll tc=dp[i][j][t]*cb[i][d*q]%md*fbs[q]%md*dcs[d-1][q]%md; tx=tx*cb[e][d]%md;e+=d; tc=tc*tx%md; dp[i-d*q][d][nx]=(dp[i-d*q][d][nx]+tc)%md; } } } ll rs;for(rs=0,i=1;i<=n;++i)rs=(rs+dp[0][i][(1<<sn)-1])%md; printf("Case %d: %I64d\n",++ct,rs);};int main(){#ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);#endif int t;scanf("%d",&t);init();while(t--)cl(); return 0;};
阅读全文
0 0
- HDU 3985 Harry Potter and the D.A.
- Harry Potter and the Hide Story HDU
- HDU 3987 Harry Potter and the Forbidden Forest 最小割
- hdu 3986 Harry Potter and the Final Battle
- HDU 3986 Harry Potter and the Final Battle
- hdu 3987 Harry Potter and the Forbidden Forest
- hdu 3991 Harry Potter and the Present II
- HDU 3988 Harry Potter and the Hide Story (数论)
- hdu 3991 Harry Potter and the Present II
- hdu 3986 Harry Potter and the Final Battle
- hdu 3988 Harry Potter and the Hide Story
- hdu 3987 Harry Potter and the Forbidden Forest
- hdu 3986 Harry Potter and the Final Battle
- HDU 3986 Harry Potter and the Final Battle
- hdu 3986 Harry Potter and the Final Battle
- 最小匹配hdu 3991 Harry Potter and the Present
- 【HDU】3987 Harry Potter and the Forbidden Forest 最小割
- HDU 3986 Harry Potter and the Final Battle(Dijkstra)
- CASE WHEN 及 SELECT CASE WHEN的用法
- appserv的安装和使用方法。
- ueditor图片无法左右对齐的解决
- 在网上看到一篇文章,挺不错的,与大家分享一下
- 2017年证券考试之金融基础考点整理
- HDU 3985 Harry Potter and the D.A.
- php fpm 启动 错误 Bad file descriptor
- java和微信的对接
- route命令
- 爬取出来的json对他进行解析出我们需要的
- PHP中file_put_contents追加和换行
- Git冲突:commit your changes or stash them before you can merge.
- 关于typedef
- poj 2406 Power Strings