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 teacher gave herthe money but didn't say
how many tickets she wanted to buy. Could Aunt Frosya determine it knowing onlythe 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 priceof 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 thatthere
is at least one variant of the answer.

Samples

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

Problem Author: Eugene Kurpilyansky, prepared by Egor Shchelkonogov

Problem Source: Ural Regional School Programming Contest 2010

解析: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.这句是关键。依照这个原则,我们确定能够买票的最小和最大钱数。然后按顺序求出能买的票数。

AC代码:

#include <bits/stdc++.h>
using namespace std; int b[6] = {10, 50, 100, 500, 1000, 5000};
set<int> ans; int main(){
#ifdef sxk
freopen("in.txt", "r", stdin);
#endif // sxk int a[6], k, sum = 0;
int t = 0;
for(int i=0; i<6; i++){
scanf("%d", &a[i]);
sum += a[i] * b[i];
if(!t && a[i]) t = b[i];
}
scanf("%d", &k);
for(int i=sum - t + 1; i <= sum; i++){
if(i % k == 0) ans.insert(i / k);
}
int n = ans.size();
printf("%d\n", n);
for(set<int>::iterator it = ans.begin(); it != ans.end(); it ++) printf("%s%d", it != ans.begin() ? " " : "", *it);
return 0;
}

URAL 1796. Amusement Park (math)的更多相关文章

  1. URAL 2025. Line Fighting (math)

    2025. Line Fighting Time limit: 1.0 second Memory limit: 64 MB Boxing, karate, sambo- The audience i ...

  2. 组合数学(math)

    组合数学(math) 题目描述 为了提高智商,zjy开始学习组合数学.某一天她解决了这样一个问题:“给一个网格图,其中某些格子有财宝.每次从左上角出发,只能往右或下走.问至少要走几次才能把财宝全部捡完 ...

  3. URAL 1069 Prufer Code(模拟)

    Prufer Code Time limit: 0.25 secondMemory limit: 8 MB A tree (i.e. a connected graph without cycles) ...

  4. Timus 1796. Amusement Park 聪明题

    On a sunny Sunday, a group of children headed by their teacher came to an amusement park. Aunt Frosy ...

  5. URAL 1741 Communication Fiend(最短路径)

    Description Kolya has returned from a summer camp and now he's a real communication fiend. He spends ...

  6. URAL 1139 City Blocks(数论)

    The blocks in the city of Fishburg are of square form. N avenues running south to north and Mstreets ...

  7. js 算數(Math)對象

    算數對象不需要聲明,可以直接使用, Math對象方法及作用: round()四捨五入: random()生成0到1的隨機數: max()選擇較大的數: min()返回較小的數:

  8. URAL 1146 Maximum Sum(DP)

    Given a 2-dimensional array of positive and negative integers, find the sub-rectangle with the large ...

  9. URAL 1306 Sequence Median(优先队列)

    题意:求一串数字里的中位数.内存为1M.每个数范围是0到2的31次方-1. 思路:很容易想到把数字全部读入,然后排序,但是会超内存.用计数排序但是数又太大.由于我们只需要第n/2.n/2+1大(n为偶 ...

随机推荐

  1. 灵活使用getconf命令来获取系统信息

    http://blog.chinaunix.net/uid-23105261-id-109513.html 灵活使用getconf命令来获取系统信息 我们时常需要查询系统相关的信息,比如页面大小,整数 ...

  2. 1、什么是Lucene,Lucene能干什么

    1.什么是lucene  Lucene是一个全文搜索框架,而不是应用产品.因此它并不像http://www.baidu.com/ 或者google Desktop那么拿来就能用,它只是提供了一种工具让 ...

  3. hdu 1300 Pearls(dp)

    Pearls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  4. Mac 安装Qt5.1编译出现的错误解决

    错误提示: :-1: 错误:Xcode is not installed in /Volumes/Xcode/Xcode.app/Contents/Developer. Please use xcod ...

  5. mma ctf 1st && csaw 2015

    (很久以前做的,现在发一下)最近做了两个CTF,水平太渣,做了没几道题,挑几个自己做的记录一下. mma ctf 1st 之 rps: from socket import * s = socket( ...

  6. 详解 CSS 属性 - 伪类和伪元素的区别(再也不用概念盲了!!!)

    首先,阅读 w3c 对两者的定义: CSS 伪类用于向某些选择器添加特殊的效果. CSS 伪元素用于将特殊的效果添加到某些选择器. 可以明确两点,第一两者都与选择器相关,第二就是添加一些“特殊”的效果 ...

  7. 浏览器的重绘(repaints)与重排(reflows)

    转:http://www.css88.com/archives/4991#more-4991 在项目的交互或视觉评审中,前端同学常常会对一些交互效果质疑,提出这样做不好那样做不好.主要原因是这些效果通 ...

  8. javascript必知必会之prototype

    本博客所有内容采用 Creative Commons Licenses 许可使用. 引用本内容时,请保留 朱涛, 出处 ,并且 非商业 . 点击 RSS 进行订阅.(推荐使用 google reade ...

  9. appium自动化测试

    appium官网:http://appium.io/index.html?lang=zh Requirements Your environment needs to be setup for the ...

  10. nginx 学习笔记【持续更新...】

    1.如果在安装过程中出现以下错误 需要安装pcre库 解决方案:yum install pcre 2.如果nginx启动提示端口被占用,则停止该端口的服务再启动nginx,一般为httpd服务 解决方 ...