Timus 1796. Amusement Park 聪明题
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
are given the price of one ticket; it is a positive integer. All the integers in the input data do not exceed 1000.
Output
It is guaranteed that there 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 |
这是一道考人是否聪明的题目,没有现成的算法。
所以须要模拟人计算的过程。用计算机的程序思维去思考。
过程这种:
1 先算出总钱数能购买多少张票
2 总钱数减去一张最小面值的钱,然后模票价,然后加上最小面值的钱,在减去一张票价。最后就得到灵活度的钱
3 灵活度的钱除以票价,就得到灵活度了,灵活度的钱除以票价得到零。那么就仅仅有一种可能了,得到1就有两种可能
难以理解的话,就细心想想人是怎样计算的就能够攻克了。
#include <iostream>
using namespace std; static const int AmusePartRoubles[6] = {10, 50, 100, 500, 1000, 5000}; void AmusementPark1796()
{
int A[6] = {0};
int money = 0;
for (int i = 0; i < 6; i++)
{
cin>>A[i];
money += A[i] * AmusePartRoubles[i];
}
int ticket = 0;
cin>>ticket;
int total = money / ticket; int i = 0;
for ( ; i < 6 && A[i] == 0; i++); int leftMoney = (money - AmusePartRoubles[i]) % ticket;
leftMoney += AmusePartRoubles[i] - ticket;
int flex = leftMoney / ticket; cout<<flex+1<<endl;
for (int j = flex; j >= 0 ; j--)
{
cout<<total - j<<' ';
}
} int main()
{
AmusementPark1796();
return 0;
}
Timus 1796. Amusement Park 聪明题的更多相关文章
- URAL 1796. Amusement Park (math)
1796. Amusement Park Time limit: 1.0 second Memory limit: 64 MB On a sunny Sunday, a group of childr ...
- CF1193A Amusement Park
洛谷 CF1193A Amusement Park 洛谷传送门 题目翻译 有一个游乐场有一个好玩的项目:一些有向滑梯可以将游客从一个景点快速.刺激地传送到另一个景点.现在,你要帮游乐场老板来规划一个造 ...
- ACDream:1210:Chinese Girls' Amusement【水题】
Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Oth ...
- hdu 4444 Walk (离散化+建图+bfs+三维判重 好题)
Walk Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submi ...
- NOIP前做题记录
鉴于某些原因(主要是懒)就不一题一题写了,代码直接去\(OJ\)上看吧 CodeChef Making Change 传送门 完全没看懂题解在讲什么(一定是因为题解公式打崩的原因才不是曲明英语太差呢- ...
- ACM刷题常用链接
武汉科技大学 http://acm.wust.edu.cn/ 华中科技大学 http://acm.hust.edu.cn/vjudge/toIndex.action 杭州电子科技大学 http:/ ...
- Codeforces 515E Drazil and Park (ST表)
题目链接 Drazil and Park 中文题面 传送门 如果他选择了x和y,那么他消耗的能量为dx + dx + 1 + ... + dy - 1 + 2 * (hx + hy). 把这个式子写成 ...
- FFT/NTT复习笔记&多项式&生成函数学习笔记Ⅲ
第三波,走起~~ FFT/NTT复习笔记&多项式&生成函数学习笔记Ⅰ FFT/NTT复习笔记&多项式&生成函数学习笔记Ⅱ 单位根反演 今天打多校时 1002 被卡科技了 ...
- 2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】
Dying Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tot ...
随机推荐
- Nginx的10万并发内核参数优化
关于内核参数的优化: net.ipv4.tcp_max_tw_buckets = 6000timewait的数量,默认是180000.net.ipv4.ip_local_port_range = 10 ...
- 通过 yum update 将系统从CentOS 6.2 升级到 CentOS 6.6 及升级过程中的简单排错
本文说明 本文写于2014年的WP中,后WP停止维护,今天翻到此记录整理下,记录于此,方便日后查看. 话说那时候写博客真是认真啊~哈哈~ 升级前的系统信息 [root@thatsit ~]# unam ...
- django: db - display
本讲介绍数据在页面中的呈现,内容很简单,就是嵌套循环在模板中的使用. 一,修改 csvt03/urls.py: from django.conf.urls import patterns, inclu ...
- 前端bug记录---不定时更新
在项目的开发中难免遇到各种各样的bug,我觉得还是有必要记录一下的,方便日后查询. safari window resize 为满足日常轮播需求,做一个符合当前业务的轮播插件,其中需要考虑windo ...
- DateTime对象反序列化的那些事
今天在Android的Json反序列化过程中,Date类型无法转化成自己想要的格式,鉴于之前在C#的反序列话中也遇到过这个问题,解决的同时,顺手做个总结,供自己及需要的人日后查阅. 将Da ...
- js中substring和substr的用法 (转)
1.substring 方法 定义和用法 substring 方法用于提取字符串中介于两个指定下标之间的字符. 语法 stringObject.substring(start,stop) 参数 ...
- 线段树hdu1754
#include<iostream>#include<stdio.h>using namespace std;const int maxa=200005;int val[max ...
- ICP编程软件配置(烧写KEIL编译后的bin文件)
1. 安装NuMicro_ICP_Programming_Tool_1.29.6425软件 2. 打开软件后选择目标芯片后点击“连接”按钮 3. 添加程序 4. 点击设定按钮进行设定 5. 点击开始 ...
- .net framework3.0 以上版本开发的软件乱码问题
首先介绍一下:WPF是微软新一代图形系统,运行在.NET Framework 3.0及以上版本下,为用户界面.2D/3D 图形.文档和媒体提供了统一的描述和操作方法.基于DirectX 9/10技术的 ...
- 3月22日 html(三)css样式表
CSS(Cascading Style Sheet,叠层样式表),作用是美化HTML网页. 一.样式表 (一)样式表的分类 1.内联样式表 和HTML联合显示,控制精确,但是可重用性差,冗余较多. 例 ...