洛谷1028
来源:互联网 发布:大众软件电子版 pdf 编辑:程序博客网 时间:2024/05/16 14:43
#include <iostream>#include <iomanip>#include <stdio.h>#include <cstring>#include <stdlib.h>using namespace std;int arr[501][1001];int main(){ int n; cin>>n; for(int i=0;i<=500;i++) { for(int j=0;j<=1000;j++) { arr[i][j]=0; } } for(int i=1;i<=1000;i++) { arr[0][i]=1; } for(int i=0;i<=n;i++) { for(int j=1;j<=i/2;j++) { for(int k=0;k<j;k++) { arr[j][i]+=arr[k][j]; } } } int sum=0; for(int i=0;i<=n/2;i++) { sum+=arr[i][n]; } cout<<sum<<endl; system("pause"); return 0;}
以下是我的递归
#include <iostream>#include <iomanip>#include <stdio.h>#include <cstring>#include <stdlib.h>#include <algorithm>#include <cmath>using namespace std;int x;int main(){ int n; int ff(int); while(cin>>n) { x=1; cout<<ff(n)<<endl; } return 0;}int ff(int n){ if(n/2==0) return x; for(int i=1;i<=n/2;i++) { ff(i); x++; } return x;}
#include <iostream>#include <iomanip>#include <stdio.h>#include <cstring>#include <stdlib.h>#include <algorithm>#include <cmath>using namespace std;int x;int main(){ int n; int ff(int); while(cin>>n) { x=1; ff(n); cout<<x<<endl; } return 0;}int ff(int n){ if(n/2==0) return x; for(int i=1;i<=n/2;i++) { ff(i); x++; }}
0 0
- 洛谷1028
- 洛谷1028
- 洛谷1028 数的计算
- 洛谷1028 数的计算
- 【题解】洛谷1028 数的计算
- 洛谷 1028——[USACO 1.3]混合牛奶 Mixing Milk
- 1028
- 1028
- 1028
- 1028
- 1028
- 1028
- 1028
- 1028
- 1028
- 1028
- 1028
- 1028
- logback.xml文件配置
- 指针总结(—)
- 泛型继承的几种写法
- HDU 1335 (16进制以下)把m进制转换为n进制
- 19.Remove Nth Node From End of List
- 洛谷1028
- Scala-02:函数定义、流程控制、异常处理入门实战
- Android四大组件之一——Broadcast Receiver
- Eclipse下如何运行微信SDK_Demo
- RxJS入门(3)----深入Sequence
- 从一个Activity直接跳转到一个Fragment中,进行相应的操作
- 数组首地址与数组名取地址的区别
- 拦截/监听器 —— Filter、Interceptor、Listener
- LeeCode-Pow(x, n)