URAL - 1796 Amusement Park(水)

Amusement Park

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

Submit 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;
	}

}
时间: 2024-10-28 20:25:58

URAL - 1796 Amusement Park(水)的相关文章

URAL 1796. Amusement Park (math)

1796. Amusement Park Time limit: 1.0 second Memory limit: 64 MB 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 t

URAL 2066 Simple Expression (水题,暴力)

题意:给定三个数,让你放上+-*三种符号,使得他们的值最小. 析:没什么好说的,全算一下就好.肯定用不到加,因为是非负数. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream>

ural 1119 Metro dp水

点击打开链接 1119. Metro Time limit: 0.5 second Memory limit: 64 MB Many of SKB Kontur programmers like to get to work by Metro because the main office is situated quite close the station Uralmash. So, since a sedentary life requires active exercises off-d

URAL - 1243 - Divorce of the Seven Dwarfs (大数取模)

1243. Divorce of the Seven Dwarfs Time limit: 1.0 second Memory limit: 64 MB After the Snow White with her bridegroom had left the house of the seven dwarfs, their peaceful and prosperous life has come to an end. Each dwarf blames others to be the re

【字源大挪移—读书笔记】 第二部分:字根

[2] 字根:[2.1]表示[否定]的字根.[2.2]表示[方位]的字根.[2.3]表示[程度]的字根.[2.4]表示[状态]的字根.[2.5]表示[现象]的字根.[2.6]表示[身体]的字根.[2.7]表示[姿势]的字根.[2.8]表示[心,心里活动]的字根.[2.9]表示[行为动作]的字根.[2.10]表示[感官动作]的字根.[2.11]表示[感觉]的字根.[2.12]表示[生命]的字根.[2.13]表示[死亡]的字根.[2.14]表示[社会]的字根 [2.1]表示[否定]的字根 -neg-

POJ3967Ideal Path[反向bfs 层次图]

Ideal Path Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 1754   Accepted: 240 Description New labyrinth attraction is open in New Lostland amusement park. The labyrinth consists of n rooms connected by m passages. Each passage is colo

听力总结

段子1(不小心把出自哪套弄没了) 听力没掌握的发音: comparison participatory trading roads that led into town 好的表达: thought-provoking architecture geography come up with a new paper topic curious I am much more into history they didn't build towns so much as they built tradi

英语新闻常用词汇与短语

英语新闻常用词汇与短语 经济篇 accumulated deficit 累计赤字 active trade balance 贸易顺差 adverse trade balance 贸易逆差 aid 援助 allocation of funds 资金分配 allotment 拨款 allowance/grant/subsidy 补贴,补助金,津贴 amortization 摊销,摊还,分期偿付 annuity 年金 article 物品,商品 assigned 过户 autarchy 闭关自守 av

公共场所英文译写规范

作者: 阮一峰 日期: 2011年1月 5日 随着国际化程度的加深,国内越来越多的公共场所开始提供英文标识. 但是,中国人的英语水平普遍不高,导致大量的翻译错误.比如,下面四个真实的例子,你能看出错在哪里吗?(答案稍后公布) * 停车场:Park * 加油站:Oil Station * 汽车租赁店:Car Rent * 请勿拍照:No Photograph 这种"中式英语"有一个专门的单词,叫做Chinglish.很多老外把它们当做笑话看. 去年,上海召开世博会,为了维护国际大都市的形