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为偶 ...
随机推荐
- 在QTableView中使用各种自定义委托
QT的MVC(View/Delegate)模型十分强大,可以利用各种控件来对表格的输入进行限制,不过我以前一直没有过,这几天研究了一下,写个小例子,希望大家喜欢. 如果看不懂这个例子,请先看QT的自带 ...
- 【C++】大数的+-*/四则运算
所谓大数,则指数值特别大的数,可能会有99位,100位,远远超过了long long表示的范围. 这样的数作四则运算,需要用到字符串.用字符串通过每一位的字符的四则运算来模拟. 废话少说,上代码: # ...
- iframe 标签自适应高度和宽度
iframe 结构如下 <iframe src="index.html" id="frame" frameborder="0" scr ...
- jquery promot
http://www.itivy.com/jquery/archive/2011/10/15/jquery-impromptu-usage.html
- mac 安装maven 和改动java环境变量
一. 首先是安装maven: 步骤: 1.下载Maven tar包 http://maven.apache.org/download.cgi 2. 下载后解压到某个目录下 [html] view pl ...
- 通过 Autostereograms 案例学习 OpenGL 和 OpenCL 的互操作性
引言 在过去的十年里, GPU (图形处理单元)已经从特殊硬件(特供)转变成能够在数值计算领域开辟新篇章的高性能计算机设备. 很多算法能够使用拥有巨大的处理能力的GPU来快速运行和处理大数据量.即使在 ...
- 总结一下.net framework适合装在哪些系统中
最近在客户这部署,环境是windows server2003 service pack2.因为vs2012开发环境是.net framework4.5,所以发布iis的时候,尝试在sever2003上 ...
- vim highlight whitespace at end of line and auto delete them
install Vundle.vim mkdir ~/.vim/bundle git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bun ...
- php学习网址
后面会陆续维护此页. 1. php编程 此博客是网站www.beilei123.cn镜像,转载请注明出处.
- Android Bitmaps缓存
Android 开发中,bitmap是引起内存泄漏的罪魁祸首,关于bitmap的加载,缓存策略,官方已经给了很详细的方法: 缓存之Memory Cache: 缓存的策略,是利用应用程序的分配的内存拿出 ...