Description FJ and his cows enjoy playing a mental game. They write down the numbers from to N ( <= N <= ) in a certain order and then sum adjacent numbers to produce a new list with one fewer number. They repeat this until only a single number is left. For example, one instance of the game (when N=) might go like this: Behind FJ's back, the cows have started playing a more difficult game, in which they try to determine the starting sequence from only the final total and the number N. Unfortunately, the game is a bit above FJ's mental arithmetic capabilities. Input Line : Two space-separated integers: N and the final sum. Output Line : An ordering of the integers ..N that leads to the given sum. If there are multiple solutions, choose the one that is lexicographically least, i.e., that puts smaller numbers first. Sample Input Sample Output Hint Explanation of the sample:
There are other possible sequences, such as 3 2 1 4, but 3 1 2 4 is the lexicographically smallest. Source 注意杨辉三角的求法,要用二维来求,其它的就没什么了。。。
#include<iostream> |
相关文章
- 10-08POJ3187 Backward Digit Sums题解
- 10-08POJ3187 Backward Digit Sums题解
- 10-08Backward Digit Sums POJ - 3187
- 10-08Backward Digit Sums POJ - 3187
- 10-08POJ 3187 Backward Digit Sums
- 10-08POJ3187Backward Digit Sums[杨辉三角]
- 10-08Backward Digit Sums(POJ 3187)
- 10-08Enum:Backward Digit Sums(POJ 3187)
- 10-08poj 3187 Backward Digit Sums(穷竭搜索dfs)
- 10-08poj3187-Backward Digit Sums(枚举全排列)