Topic Overview
We ask to find the number of numbers with the following properties (including the natural number of input n):
First enter a natural number n (n≤1000), and then the natural number is processed according to the following method
1. Not to make any treatment;
2. Add a natural number to the left of it, but the natural number cannot exceed half of the original number;
3. After adding the number, continue to follow this rule until no more natural numbers can be established.
Input
A natural number n.
Output
An integer, the total number.
Ideas for solving problems
I have to say that it is really ... Very good! A chestnut said: if n = 6, there will be the following number of regeneration:
6, 16, 26, 126, 36, 136
Extracts the highest digit x of the current number, which may produce a number of X/2.
Add the final result to the X/2.
Problems encountered
A problem with an AC rate of 83% doesn't seem to run into any problems. 0 0
Source
#include <iostream>
void getnumbers (int n, int& counter) {
counter + = N/2;
for (int i = 1; I <= N/2 + i) {
getnumbers (i, counter);
}
}
int main () {
int n = 0, counter = 1;
Std::cin >> N;
Getnumbers (n, counter);
Std::cout << counter << Std::endl;
return 0;
}
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/