POJ 3187 Backward Digit Sums next_permutation()使用
来源:互联网 发布:驾校模拟驾驶软件 编辑:程序博客网 时间:2024/05/16 11:06
Backward Digit Sums
Time Limit: 1000MS Memory Limit: 65536K
Description
FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) 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=4) might go like this:
Write a program to help FJ play the game and keep up with the cows.
3 1 2 4Behind 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.
4 3 6
7 9
16
Write a program to help FJ play the game and keep up with the cows.
Input
Line 1: Two space-separated integers: N and the final sum.
Output
Line 1: An ordering of the integers 1..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
4 16
Sample Output
3 1 2 4
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.
There are other possible sequences, such as 3 2 1 4, but 3 1 2 4 is the lexicographically smallest.
- POJ 3187 Backward Digit Sums next_permutation()使用
- POJ 3187 Backward Digit Sums(next_permutation)
- poj 3187 Backward Digit Sums【next_permutation】
- POJ 3187 Backward Digit Sums 【穷竭搜索 next_permutation函数】
- POJ 3187 Backward Digit Sums(next_permutation()暴力枚举)
- POJ 3187 Backward Digit Sums(next_permutation()+ 组合数)
- POJ 题目Backward Digit Sums(next_permutation)
- POJ 3187 Backward Digit Sums
- POJ 3187 Backward Digit Sums
- POJ 3187 Backward Digit Sums
- poj 3187 Backward Digit Sums
- POJ-3187-Backward Digit Sums
- poj 3187 Backward Digit Sums
- POJ-3187-Backward Digit Sums
- poj 3187 : Backward Digit Sums
- poj 3187 Backward Digit Sums
- POJ 3187 Backward Digit Sums
- POJ 3187 Backward Digit Sums
- 快乐王子
- Ubuntu 10.10 设置firefox字体
- 监测桥梁的无线智能传感器网络
- (转)CRectTracker类的使用
- unix 和 dos 中换行的区别
- POJ 3187 Backward Digit Sums next_permutation()使用
- Android Thread Looper Handler 关系
- 在应用程序中加入调试窗口
- linux 客户端 Socket 非阻塞connect编程
- Sonic Heroes组队必杀
- 根据计算机名称获得ip地址
- objective-c 特性快速一覽表
- Sonic Heroes- game doohickey
- 双链表