-->
当前位置:首页 > 题库

PROGRAMMING:The integer is decomposed into the sum of several terms

Luz5年前 (2021-05-10)题库409
There are many ways to decompose a positive integer n into several positive integers, such as 7 = 6 + 1, 7 = 5 + 2, 7 = 5 + 1 + 1. Program to find all integer decomposition formulas of positive integer n.
###Input format:
Each input contains a test case, which is a positive integer n (0 $$< $$n $$$Le $$30).
###Output format:
Output all integer decompositions of N in increasing order. The incremental order is: for two decomposition sequences $$n_ 1=$${$$n_ 1, n_ 2, cdots $$} and $$n_ 2=$${$$m_ 1, m_ 2, if there is $$I $$such that $$n_ 1=m_ 1, \cdots , n_ i=m_ I $$, but $$n_{ i+1} < m_{ I + 1} $$, then $$n_ 1 $$sequence must be in $$n_ 2 $$sequence. Each formula is added from small to large, separated by semicolons, and each output of 4 formulas is followed by a new line.
###Input example:
```in
seven
```
###Output example:
```out
7=1+1+1+1+1+1+1; 7=1+1+1+1+1+2; 7=1+1+1+1+3; 7=1+1+1+2+2
7=1+1+1+4; 7=1+1+2+3; 7=1+1+5; 7=1+2+2+2
7=1+2+4; 7=1+3+3; 7=1+6; 7=2+2+3
7=2+5; 7=3+4; 7=7
```






answer:If there is no answer, please comment