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为偶 ...
随机推荐
- linux下so动态库一些不为人知的秘密(上)
linux 下有动态库和静态库,动态库以.so为扩展名,静态库以.a为扩展名.二者都使用广泛.本文主要讲动态库方面知识. 基本上每一个linux 程序都至少会有一个动态库,查看某个程序使 ...
- 带有OUTPUT的INSERT,DELETE,UPDATE
原文地址:http://blog.sina.com.cn/s/blog_71460d950100nld2.html OUTPUT是SQL SERVER2005的新特性.可以从数据修改语句中返回输出.可 ...
- HDOJ-1002 A + B Problem II (非负大整数相加)
http://acm.hdu.edu.cn/showproblem.php?pid=1002 输入的数都是正整数,比较好处理,注意进位. //非负大整数加法 # include <stdio.h ...
- 关于xxx.h file not found 的问题
在引用第三方库的时候,经常会遇到xxx.h file not found的问题. 首先,我们要知道在引用第三方的时候,我们使用的第三方的库的类型. .a静态库 使用方式:#import "x ...
- 又一道简单题&&Ladygod(两道思维水题)
Ladygod Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit S ...
- Truck History(kruskal+prime)
Truck History Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Tota ...
- 移植busybox-1.21.1
busybox官网:www.busybox.net 1.解压 # tar jxvf busybox-1.21.1.tar.bz2 2.配置 # cd busybox-1.21.1 # make men ...
- 如何确定Ubuntu下是否对某个CVE打了补丁
前些日子在月赛中,拿到了一台Ubuntu14.04的服务器,但并不是root权限,需要提权.我Google了一下,找到了CVE-2015-1318,CVE-2015-1328,CVE-2015 ...
- ORACLE数据库存储结构简介(转)
首先,oracle数据库的存储结构可以分为逻辑存储结构和物理存储结构,对于这两种存储结构,oracle是分别进行管理的. 逻辑存储结构:oracle内部的组织和管理数据的方式. 物理存储结构:o ...
- css单位和值
css需要单位来度量.内含整数.小数.百分数的情况,很多条件下支持正负的情况,当然是有限制的了.百分数基本是相对于自身.或是父或是祖先元素的某个属性值. 颜色 颜色的表示分为:命名颜色 ...