码迷,mamicode.com
首页 > 其他好文 > 详细

URAL - 1796 Amusement Park(水)

时间:2015-04-21 09:44:15      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u

 Status

Description

On a sunny Sunday, a group of children headed by their teacher came to an amusement park. Aunt Frosya, who was a very kind and quiet person, worked at the ticket window on that day. The teacher gave her the money but didn‘t say how many tickets she wanted to buy. Could Aunt Frosya determine it knowing only the numbers of different notes the teacher gave? It is assumed that the teacher didn‘t give extra notes, which means that there would not be enough money for the tickets if any of the notes was taken away.

Input

The first line contains six nonnegative integers separated with a space; these are the numbers of 10, 50, 100, 500, 1000, and 5000 rouble notes the teacher gave to Aunt Frosya. In the second line you are given the price of one ticket; it is a positive integer. All the integers in the input data do not exceed 1000.

Output

Find the number of tickets the teacher wanted to buy. Output the number of possible answers in the first line. The variants in ascending order separated with a space must be given in the second line. It is guaranteed that there is at least one variant of the answer.

Sample Input

input output
0 2 0 0 0 0
10
5
6 7 8 9 10
1 2 0 0 0 0
10
1
11

上限是sum/m,下限是sum-最小面值的一个还要再加一。

#include<iostream>
using namespace std;
int a[10];
void init()
{
	a[0] = 10;
	a[1] = 50;
	a[2] = 100;
	a[3] = 500;
	a[4] = 1000;
	a[5] = 5000;
}
int b[10];
int main()
{
	init();
	int m;
	while (cin >> b[0])
	{
		cin >> b[1] >> b[2] >> b[3] >> b[4] >> b[5];
		cin >> m;
		int min;
		for (int i = 0; i < 6; i++)
		{
			if (b[i])
			{
				min = i; break;
			}
		}
		int sum = 0;
		for (int i = 0; i <6; i++)
			sum = sum + b[i] * a[i];
		int high = sum / m;
		int low=(sum -  a[min]) / m;
		cout << high - low << endl;
		for (int i = low+1; i <= high; i++)
			cout << i << " ";
		cout << endl;
	}

}


URAL - 1796 Amusement Park(水)

标签:

原文地址:http://blog.csdn.net/qq_18738333/article/details/45161577

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!