HDOJ1028 Ignatius and the Princess III
来源:互联网 发布:淘宝情侣装店铺名称 编辑:程序博客网 时间:2024/06/07 06:33
64以前DFS,65以后打表- -
#include "stdio.h"int count=0;int ans[56]={2012558,2323520,2679689,3087735,3554345,4087968,4697205,5392783,6185689,7089500,8118264,9289091,10619863,12132164,13848650,15796476,18004327,20506255,23338469,26543660,30167357,34262962,38887673,44108109,49995925,56634173,64112359,72533807,82010177,92669720,104651419,118114304,133230930,150198136,169229875,190569292,214481126,241265379,271248950,304801365,342325709,384276336,431149389,483502844,541946240,607163746,679903203,761002156,851376628,952050665,1064144451,1188908248,1327710076,1482074143,1653668665,1844349560};int answer[121];int min(int a,int b){return a<b?a:b;}int DFS(int previous,int remain){int i,j,k=0;if(previous>=remain){if(answer[remain])return answer[remain];else{for(i=1;i<=remain;i++)k+=DFS(i,remain-i);answer[remain]=k;return k;}}else{k=0;for(i=1;i<=previous;i++)k+=DFS(i,remain-i);return k;}}int main(){int n,i;answer[0]=answer[1]=1;answer[2]=2;answer[3]=3;answer[4]=5;answer[5]=7;answer[6]=11;answer[7]=15;answer[8]=22;for(i=9;i<=120;i++)answer[i]=0;while(scanf("%d",&n)!=EOF){if(n>=65)printf("%d\n",ans[n-65]);else printf("%d\n",DFS(32767,n));}}
0 0
- HDOJ1028 Ignatius and the Princess III
- 母函数之Ignatius and the Princess III hdoj1028
- hdoj1028 Ignatius and the Princess III(整数分解)
- hdoj1028 Ignatius and the Princess III (母函数-整数拆分)
- hdoj1028 Ignatius and the Princess III(母函数,生成函数)
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- Ignatius and the Princess III
- cocos2d-x实现3d翻转
- bitmap size exceeds 32bits
- 素数对 交大OJ2114
- WebService基于SoapHeader实现安全认证
- 和小白一起学ABAP – 17 SAP程序设计之 应用事务开发
- HDOJ1028 Ignatius and the Princess III
- xsd文件的定义
- 《Programming in Lua 3》读书笔记(八)
- altium designer 常用元件封装
- HDOJ1029 Ignatius and his princess IV
- [工具推荐] mupdf
- 第二十周自由练习项目——acm 对象转换
- 无废话MVC入门教程一[概述、环境安装、创建项目]
- 学习javacv之二:javacv0.8开发环境的搭建