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 ...
随机推荐
- Python-elementTree方法解析xml文件-01
[XML基本概念介绍] XML 指可扩展标记语言(eXtensible Markup Language). XML 被设计用来传输和存储数据.概念一: <foo> # foo元素的起始标签 ...
- LDAP-常用命令
1.recreating default ads instance ./ [root@dhcppc2 ~]# dsadm delete /usr/local/dsee7/var/dcc/ads #de ...
- 一小时搞定DIV+CSS布局-固定页面开度布局
本文讲解使用DIV+CSS布局最基本的内容,读完本文你讲会使用DIV+CSS进行简单的页面布局. 转载请标明:http://www.kwstu.com/ArticleView/divcss_20139 ...
- CSS选择器列表
h1 类型选择器 选择元素的一个类型 .className 类选择器 以class属性的值来选择元素,可以在一个页面中出现多个 #idName ID选择器 以id属性的值来选择元素,在页面中是唯一的, ...
- js生成随机数的方法小结
js生成随机数主要用到了内置的Math对象的random()方法.用法如:Math.random().它返回的是一个 0 ~ 1 之间的随机数.有了这么一个方法,那生成任意随机数就好理解了.比如实际中 ...
- 使用Gird++打印出现“Retrieving the COM class factory for component with CLSID”的解决办法
我们的接口需要返回一个gird++生成PDF文件的二进制数据,在本地测试都很好,发布到服务器上一直出现“Retrieving the COM class factory for component w ...
- 自定义悬浮按钮:FloatingButton
floating_button_layout.xml <?xml version="1.0" encoding="utf-8"?> <Rela ...
- Carthage使用(cocoapods的替代)
1.使用homebrew安装Carthage brew intsall carthage Ps:没有安装Homebrew的话,进入传送门Homebrew.顺便提一句可以选择简体中文啊. 2.进入 ...
- 包装 request Demo
//包装request,增强getParameter方法 class MyReq extends HttpServletRequestWrapper{ private HttpServletReque ...
- dom的element类型
1)getElementById 后面的nodeName和tagName都一样 var a=document.getElementById("my_div"); console.l ...