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 ...
随机推荐
- javascript eval和JSON之间的联系(转)
eval函数的工作原理 eval函数会评估一个给定的含有JavaScript代码的字符串,并且试图去执行包含在字符串里的表达式或者一系列的合法的JavaScript语句.eval函数将把最后一个表达式 ...
- Win10开发必备工具:Visual Studio 2015正式版下载
7月21日凌晨最新消息,面向大众用户的Visual Studio 2015集成开发工具正式版免费试用版已经推出.本文帮大家汇总一下简体中文社区版.专业版以及企业版在线安装版以及ISO离线安装镜像下载地 ...
- gulp前端自动化构建工具新手入门篇
很久没有更新博文了. 经过了一次年前吐血的赶项目,终于在年后回血了.趁着有空,新学到了一个前端自动化构建工具-gulp. 现在我们通过这3个问题来学习一下: 1.什么是gulp? 2.为什么要用gul ...
- Could not find the Visual SourceSafe Internet Web Service connection information
Visual SourceSafe Internet---------------------------Could not find the Visual SourceSafe Internet W ...
- 《第一行代码》学习笔记38-服务Service(5)
1.希望服务一旦启动就立刻去执行某个动作,可以将逻辑写在onStartCommand()方法里. 2.onCreate()和onStartCommand()的区别:onCreate()方法是在服务第一 ...
- innodb_flush_method参数解析
innodb_flush_method这个参数控制着innodb数据文件及redo log的打开.刷写模式,对于这个参数,文档上是这样描述的:有三个值:fdatasync(默认),O_DSYNC,O_ ...
- poj1988 简单并查集
B - 叠叠乐 Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:30000KB 64bit ...
- UVA10090 数论基础 exgcd
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- 翻译:《What can I hold you with?》—— 博尔赫斯《英文诗两首》之一。
What can I hold you with? 我拿什么才能留住你? I offer you lean streets, desperate sunsets, the moon of the ja ...
- uva 11038 - How Many O's?
想法: 將問題簡化為求1~m 0的總數,以及1~n 0的總數,然後最後再相減. 求1~n 0的總數,要將n分別算每個位數0的個數,舉例如30324: 先從右邊第一位'4'開始,其左邊為3032,表示1 ...