五角数定理!!可以参考这个http://www.cnblogs.com/xin-hua/p/3242428.html

 代码如下:

 #include<iostream>
#include<stdio.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#define ll __int64
#define pi acos(-1.0)
#define MAX 100001
using namespace std;
const int mod=;
int an[MAX],n,t,k;
void init(){
int i,j;
an[]=an[]=;
an[]=;an[]=;an[]=;
an[]=;
for(i=;i<MAX;i++){
an[i]=;
for(j=;;j++){
int g=j*(*j-)/;
if(i-g<) break;
if(j&) an[i]+=an[i-g];
else an[i]-=an[i-g];
an[i]=an[i]%mod;
while(an[i]<) an[i]+=mod;
g=j*(*j+)/;
if(i-g<) break;
if(j&) an[i]+=an[i-g];
else an[i]-=an[i-g];
an[i]=an[i]%mod;
while(an[i]<) an[i]+=mod;
}
an[i]%=mod;
}
}
int solve()
{
int ans=an[n];
for(int j=;;j++){
int g=k*j*(*j-)/;
if(n-g<) break;
if(j&) ans-=an[n-g];
else ans+=an[n-g];
ans=ans%mod;
while(ans<) ans+=mod;
g=k*j*(*j+)/;
if(n-g<) break;
if(j&) ans-=an[n-g];
else ans+=an[n-g];
ans=ans%mod;
while(ans<) ans+=mod;
}
return ans%mod;
}
int main(){
init();
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&k);
printf("%d\n",solve());
}
return ;
}

hdu 4658 Integer Partition的更多相关文章

  1. hdu 4651 Partition && hdu 4658 Integer Partition——拆分数与五边形定理

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4651 参考:https://blog.csdn.net/u013007900/article/detail ...

  2. HDU 4658 Integer Partition (2013多校6 1004题)

    Integer Partition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  3. HDU 4658 Integer Partition(整数拆分)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4658 题意:给出n.k.求n的拆分方案数.要求拆分中每个数不超过k. i64 f[N]; void i ...

  4. 【hdu 4658】Integer Partition (无序分拆数、五边形数定理)

    hdu 4658 Integer Partition 题意 n分拆成若干个正整数的和,每个正整数出现小于k次,分拆方案有多少.(t<=100,n<=1e5) 题解 之前写过一篇Partit ...

  5. Integer Partition(hdu4658)2013 Multi-University Training Contest 6 整数拆分二

    Integer Partition Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...

  6. hdu 1047 Integer Inquiry

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...

  7. HDU 3208 Integer’s Power

    Integer’s Power Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Origina ...

  8. hdu acm-1047 Integer Inquiry(大数相加)

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. hdu 1047 Integer Inquiry(高精度数)

    Problem Description Oneof the first users of BIT's new supercomputer was Chip Diller. He extended hi ...

随机推荐

  1. 设置Oracle 12C OEM 端口

    SQL);   打开OEM: http://DBSIPOrName:8087/em/

  2. KVC/KVO总结

    KVC(键值编码) 动态设置: setValue:属性值 forKey:属性名(用于简单路径) setValue:属性值 forKeyPath:属(用于复合路径,例如Person有一个Account类 ...

  3. info sed 中文不完全文档

    快速指南: sed 的一般使用方法:sed -option 'adress|command' -f scpritfiles(1)'|' 只是用来说明性的分隔 adress 和 command,实际使用 ...

  4. 返璞归真vc++之感言

    本人自述,大专学历,感觉自己也属于好学型学生,历任班上学习委员3年有余,参与学校项目几多个,不知道不觉从11年毕业已有3个年头,3年来,不敢苟同自己的生活方式,奈何人生无奈..从刚开始的电子商务公司转 ...

  5. HTML5之缓存

    ----- 缓存文件 - 使用UTF-8编码- 以Cache Manifest 开头- 三个基本部分 CACHE MANIFESTmenu.htmlmenu.js# login requires ne ...

  6. 隐藏win7盘符

    1.隐藏盘符: //新建注册表,隐藏X盘符 int regeditme() { HKEY hkey; DWORD dwLastError= ;//隐藏X盘2^25 J:2^9=512 X:盘符与挂载的 ...

  7. 锋利的jquery-validation

    jquery插件 jquery插件项目托管于gitHub,项目地址https://github.com/jquery/plugins.jquery.com jquery插件的使用 表单验证插件 现在网 ...

  8. WinForms 小型HTML服务器

    最近教学,使用到了Apache和IIS,闲着无聊,有种想自己写个小服务器的冲动. 在网上找了半天的资料,最后终于搞定了,测试可以访问.效果图如下: 因为只是处理简单的请求,然后返回请求的页面,所以没有 ...

  9. aix 安装redis

    下载最新rpm安装包 http://www.perzl.org/aix/index.php?n=Main.Redis # uname -aAIX rhjf 1 6 00C5CC964C00# pwd/ ...

  10. Python urllib2 模块学习笔记

    2015.3.6  urllib2的使用方法大致如下 # 定制Handler处理函数 opener = urllib2.build_opener(ProxyHandler, HTTPHandler) ...