luogu P1028 [NOIP2001 Popularization Group] Calculation of the number

P1028

Title description
We ask to find the number of the following properties (including the input positive integer nn).

First enter a positive integer nn (n \le 1000n≤1000), and then process this positive integer as follows:

Do nothing

Add a positive integer to its left, but the positive integer cannot exceed half of the original number;

After adding the number, continue processing according to this rule until no more positive integers can be added.

Input format
11 positive integers nn(n \le 1000n≤1000)

The output format is
11 integers, representing the number of numbers with this property.

Input and output sample
input #1 copy
6
output #1 copy
6
description/prompt
The number that meets the condition is

6,16,26,126,36,136

[Subject source]

NOIP 2001 Universal Group Question 1

Find the law recursively

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
int f[1005];
int main(){
    
    
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
    
    
		for(int j=1;j<=i/2;j++){
    
    
			f[i]+=f[j];
		}
		f[i]++;
	}
	cout<<f[n];
	return 0;
	
}

Guess you like

Origin blog.csdn.net/Minelois/article/details/113854870
Recommended