hdu 1028 Ignatius and the Princess III(一个数加法有几种)
来源:互联网 发布:军鸽软件 编辑:程序博客网 时间:2024/05/20 20:01
//hdu 1028 Ignatius and the Princess III(一个数加法有几种)#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int M = 129;long long df[M][M];//============================/*df[i][j]二维数组数组i存取所要得的数据,j是j公式加法中最大的一个加数值比如n=4,i=4等式的值M有可能为1,2,3,4df[4][1]=1 --> 4=1+1+1+1;df[4][2]=df[2][2]+df[4][1] =3--> 4= 1+1+1+1;4=2+1+1;4=2+2;df[4][3]=df[1][1]+df[4][2]=4 -->4= 1+1+1+1;4=2+1+1;4=2+2;4=3+1;df[4][4]=df[0][0]+df[4][3]=5 -->4= 1+1+1+1;4=2+1+1;4=2+2;4=3+1;4=4;注意:if(j>i-j) df[i][j] = df[i - j][i-j] + df[i][j-1]; else df[i][j] = df[i - j][j] + df[i][j-1];*///============================void init(){ int i, j, temp; df[0][0] = 1; for (int i = 1; i < M; ++i) df[i][1] = 1; for (int i = 2; i < M; ++i) for (int j = 2; j <= i; ++j) { if (j > i - j) temp = i-j; else temp = j; df[i][j] = df[i - j][temp] + df[i][j-1]; }}//=============================int main(){ init(); int n; while (scanf("%d", &n) ==1) { printf("%lld\n", df[n][n]); } return 0;}
0 0
- hdu 1028 Ignatius and the Princess III(一个数加法有几种)
- hdu 1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- HDU-1028-Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- HDU--1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- 四、配置与调试
- 后缀数组模板
- LeetCode Remove Duplicates from Sorted Array II
- hdu 1005 Number Sequence
- 【适合初学者】简单代码讲述json数据与oc对象互相转化
- hdu 1028 Ignatius and the Princess III(一个数加法有几种)
- linux软件管理器
- C++中Vector的常见使用方法
- java io重定向
- Python yield 使用浅析
- (二)正则表达式之常用表达式详细解析
- poj 3692 最大独立点集
- BFS模板
- WPF一些概念的区别