Title Description
We asked to find the number (n comprises a natural number entered) having the following properties Number:
input a natural number n (n <= 1000), then this processing natural number as follows:
Without any treatment;
in its left plus a natural number, but the number of natural numbers can not exceed half of the original;
plus the number, this rule continues the process until it can not be combined with natural numbers so far.
Input and output formats
Input formats:
A natural number n (n <= 1000)
Output formats:
An integer that indicates the number with the number of properties.
Input Output Sample
Input Sample # 1:
6
Output Sample # 1:
6
----------------
ideas: recursive problem, look for a recursive formula, from the beginning to find the law.
#include<cstdio>
#include<iostream>
using namespace std;
int h[1001];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
h[i]=1;
for(int j=1;j<=i/2;j++)
h[i]+=h[j];
}
cout<<h[n];
return 0;
}