当前位置:网站首页>P2404 splitting of natural numbers
P2404 splitting of natural numbers
2022-07-24 21:33:00 【A little Yu】
Copy Markdown an
Title Description
Any one is greater than 11 The natural number of nn, It can be divided into several smaller than nn The sum of the natural numbers of . Now I'll give you a natural number nn, Ask you to find out nn Split into some numbers and . The numbers in each split sequence are sorted from small to large . Then you need to output these sequences , Among them, the sequence with small dictionary order needs to be output first .
Input format
Input : Natural number to be split nn.
Output format
Output : The addition formula of some numbers .
I/o sample
Input #1 Copy
7
Output #1 Copy
1+1+1+1+1+1+1 1+1+1+1+1+2 1+1+1+1+3 1+1+1+2+2 1+1+1+4 1+1+2+3 1+1+5 1+2+2+2 1+2+4 1+3+3 1+6 2+2+3 2+5 3+4
explain / Tips
Data assurance ,1<=n<=8
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int a[10001]= {1};
int n;
void print(int t)
{
for(int i=1; i<=t-1; i++)
cout<<a[i]<<"+";
cout<<a[t]<<endl;
}
void dfs(int s,int t)
{
for(int i=a[t-1]; i<=s; i++)// Greater than or equal to the previous digit
{
if(i<n)
{
a[t]=i;
s-=i;
if(s==0) print(t);
else dfs(s,t+1);
s+=i;
}
}
}
int main()
{
cin>>n;
dfs(n,1);
return 0;
}
边栏推荐
- 支付宝上股票开户安全吗
- Information System Project Manager - Chapter 10 project communication management and project stakeholder management
- Penetration test - command execution injection
- Es+redis+mysql, the high availability architecture design is awesome! (supreme Collection Edition)
- [summary of Feature Engineering] explain what features are and the steps of feature engineering
- C local functions and yield statements
- OSI的体系结构,以及各层协议
- Acwing 94. recursive implementation of permutation enumeration
- Overview and installation of scientific computing toolkit scipyscipy
- RESNET interpretation and 1 × 1 Introduction to convolution
猜你喜欢

ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘ (10061)

RESNET interpretation and 1 × 1 Introduction to convolution

Using skills and design scheme of redis cache (classic collection version)

Eight transformation qualities that it leaders should possess

Selenium test page content download function

MySQL - multi table query - seven join implementations, set operations, multi table query exercises

Sword finger offer 15. number of 1 in binary

Gather relevant knowledge points and expand supplements
![[basic data mining technology] exploratory data analysis](/img/0c/1b73098a589a2af398dd3cd9d62cd7.png)
[basic data mining technology] exploratory data analysis

【MLFP】《Face Presentation Attack with Latex Masks in Multispectral Videos》
随机推荐
Is it safe for Hengtai securities to open an account?
Can century model simulate soil respiration? Practice technology application and case analysis of century model
C # image template matching and marking
Overloaded & lt; for cv:: point;, But VS2010 cannot find it
支付宝上股票开户安全吗
Scientific computing toolkit SciPy image processing
Unfair distribution
Five digital transformation strategies of B2B Enterprises
Drawing library Matplotlib drawing
Career development suggestions shared by ten CIOs
[record of question brushing] 16. The sum of the nearest three numbers
How to design the order system in e-commerce projects? (supreme Collection Edition)
How about Urumqi Shenwan Hongyuan securities account opening? Is it safe?
[feature selection] several methods of feature selection
MQ release confirmation
rogabet note 1.1
Information System Project Manager - Chapter 10 project communication management and project stakeholder management
The maximum number of expressions in ora-01795 list is 1000
Smarter! Airiot accelerates the upgrading of energy conservation and emission reduction in the coal industry
Can bank financial products be redeemed and transferred out on the same day?