URAL - 1796 Amusement Park(水)
2015-04-21 01:18
323 查看
Amusement Park
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
上限是sum/m,下限是sum-最小面值的一个还要再加一。
Time Limit: 1000MS | Memory Limit: 65536KB | 64bit IO Format: %I64d & %I64u |
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 |
#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 (math)
- URAL 1796 Amusement Park
- URAL 1796. Amusement Park (math)
- Timus 1796. Amusement Park 聪明题
- Timus 1796. Amusement Park 聪明题
- URAL 1133 Fibonacci Sequence(数论)
- ural 1057 Amount of degrees 【数位dp】
- URAL - 1966 - Cycling Roads(并查集 + 判线段相交)
- Ural 1207. Median on the Plane(计算几何)
- URAL 2014 Zhenya moves from parents --线段树
- ural 2030
- HDU 1796 How many integers can you find(容斥原理)
- URAL 1146. Maximum Sum
- 【神题】URAL 1575 Yekaterinburg Subway 2
- URAL 1491. Unreal Story(区间染色, 数学啊)
- URAL 1517 Freedom of Choice 后缀数组 入门
- URAL 1244 Gentlemen
- Ural1209(数学推导)
- URAL 1296. Hyperjump(最大子序列和)
- Ural1349(费马大定理)