URAL 1796. Amusement Park (math)
1796. Amusement Park
Memory limit: 64 MB
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
ticket; it is a positive integer. All the integers in the input data do not exceed 1000.
Output
is at least one variant of the answer.
Samples
| input | output |
|---|---|
0 2 0 0 0 0 |
5 |
1 2 0 0 0 0 |
1 |
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)的更多相关文章
- URAL 2025. Line Fighting (math)
2025. Line Fighting Time limit: 1.0 second Memory limit: 64 MB Boxing, karate, sambo- The audience i ...
- 组合数学(math)
组合数学(math) 题目描述 为了提高智商,zjy开始学习组合数学.某一天她解决了这样一个问题:“给一个网格图,其中某些格子有财宝.每次从左上角出发,只能往右或下走.问至少要走几次才能把财宝全部捡完 ...
- URAL 1069 Prufer Code(模拟)
Prufer Code Time limit: 0.25 secondMemory limit: 8 MB A tree (i.e. a connected graph without cycles) ...
- Timus 1796. Amusement Park 聪明题
On a sunny Sunday, a group of children headed by their teacher came to an amusement park. Aunt Frosy ...
- URAL 1741 Communication Fiend(最短路径)
Description Kolya has returned from a summer camp and now he's a real communication fiend. He spends ...
- URAL 1139 City Blocks(数论)
The blocks in the city of Fishburg are of square form. N avenues running south to north and Mstreets ...
- js 算數(Math)對象
算數對象不需要聲明,可以直接使用, Math對象方法及作用: round()四捨五入: random()生成0到1的隨機數: max()選擇較大的數: min()返回較小的數:
- URAL 1146 Maximum Sum(DP)
Given a 2-dimensional array of positive and negative integers, find the sub-rectangle with the large ...
- URAL 1306 Sequence Median(优先队列)
题意:求一串数字里的中位数.内存为1M.每个数范围是0到2的31次方-1. 思路:很容易想到把数字全部读入,然后排序,但是会超内存.用计数排序但是数又太大.由于我们只需要第n/2.n/2+1大(n为偶 ...
随机推荐
- boost库的安装,使用,介绍,库分类
1)首先去官网下载boost源码安装包:http://www.boost.org/ 选择下载对应的boost源码包.本次下载使用的是 boost_1_60_0.tar.gz (2)解压文件:tar - ...
- C#基础:委托 【转】
委托是C#中最为常见的内容.与类.枚举.结构.接口一样,委托也是一种类型.类是对象的抽象,而委托则可以看成是函数的抽象.一个委托代表了具有相同参数列表和返回值的所有函数.比如: delegate in ...
- Linux基本配置和管理 4 ---- Linux系统启动详解
1 系统启动的流程 BIOS -> MBR+boot code -> 执行引导程序: GRUB -> 加载内核 -> 执行init -> 运行runlevel 2 启动详 ...
- 《面试题精选》15.O(logn)求Fibonacci数列
题目:定义Fibonacci数列例如以下: / 0 n=0 f(n)= 1 n=1 ...
- 【floyd求最小环】【Vijos 1046】【观光旅游】
标签:图结构 最短路 题目大意:给你一个无向图,至少经过3个节点的简单回路(不能包括其他环) 一开始的思路:用一个NUM[i][j]表示i到j的最短路经过几个节点,显然解法不太优美,而且还是错的 再想 ...
- 视频编解码学习之路(H264)
学习视频编解码技术很难吗?视频编解码技术的未来是什么? 明了的说,无论是软件还是硬件设计,视频编解码技术有很多难点,都需要很长一段时间积累才行. 从一开始接触MPEG-2到最新的H.264标准,可算走 ...
- jQuery的主要用法
一.选择网页元素jQuery的基本设计和主要用法,就是"选择某个网页元素,然后对其进行某种操作".这是它区别于其他函数库的根本特点. 使用jQuery的第一步,往往就是将一个选择表 ...
- servlet+ajax+json字符串后台传入,前端解析并把数据循环填入表格实例
写在前面:1.源代码来源于博客http://blog.sina.com.cn/u/2904067371 ,在此基础上对于前端代码稍作更改,把传过来的数据解析并传入表格2.json解析,用eval()3 ...
- java工厂类与反射机制
java 简单工厂类 2012-04-22 15:44:07| 分类: java | 标签:java工厂类 简单工厂类 |举报|字号 订阅 简单工厂模式需要由以下角色组成: 接口 ...
- 新炬学院OCM讲师《Oracle核心技术》译作面世
对于数据库爱好者来讲,Oracle是最值得研究的数据库.学习Oracle数据库时,一本好书的引导和启发是非常必要的,毫无疑问,<Oracle核心技术>就是这样一本好书. <Oracl ...