UVALive 6084 Happy Camper(数学题)
----------------------------------------------------------------------------------------------------------------------------------------------------------
欢迎光临天资小屋:http://user.qzone.qq.com/593830943/main
----------------------------------------------------------------------------------------------------------------------------------------------------------
As Happy Camper Harry pulls into his favorite campground with his family, he notices the sign:
'Campground occupancy is limited to 10 days within any consecutive 20-day period.' Harry is just
starting a 28-day vacation. What is the maximum number of days he can occupy a campsite during
his vacation?
We state the problem in more general terms. Suppose that 1 < L < P < V are integers. Camp-
ground occupancy is limited to L days within any consecutive P-day period. Happy Camper Harry
is just starting a V -day vacation. What is the maximum number of days he can occupy a campsite
during his vacation?
Input
The input will contain data for a number of test cases. For each test case, there will be one line of data,
containing values of L, P and V , in that order. All input integers can be represented by signed 32-bit
integers. End of data will be signaled by a line containing three zeros, which will not be processed.
Output
There will be one line of output for each test case. It will display the case number and the number of
days Happy Camper Harry can occupy a campsite during his vacation. The format is illustrated by
the sample output.
Sample Input
5 8 20
5 8 17
0 0 0
Sample Output
Case 1: 14
Case 2: 11
代码例如以下:
#include<stdio.h>
#define ll long long
int main()
{
ll l,p,v;
ll ans,temp;
int cas=1;
while(scanf("%lld %lld %lld",&l,&p,&v)!=EOF)
{
if(l==0 && p==0 && v==0)
break;
temp=v%p;
if(temp>=l)
{
temp = l;
}
ans=(v/p)*l+temp; printf("Case %d: ",cas++);
printf("%lld\n",ans);
}
return 0;
}
UVALive 6084 Happy Camper(数学题)的更多相关文章
- Gym 101194H / UVALive 7904 - Great Cells - [数学题+快速幂][2016 EC-Final Problem H]
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?opti ...
- UVALive 5840 数学题
DES:给出三种材料A,B,C每种的个数.然后组合AB,BC,AC的利润.问能获得的最大利润是多少. 开始一点思路都没有.然后发现可以枚举其中两种的个数.那么最后一种就确定了.还是感觉很机智. #in ...
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
- ytu 2558: 游起来吧!超妹!(水题,趣味数学题)
2558: 游起来吧!超妹! Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 7 Solved: 3[Submit][Status][Web Board ...
- sdut 2416:Fruit Ninja II(第三届山东省省赛原题,数学题)
Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive 6145 Version Controlled IDE(可持久化treap、rope)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
随机推荐
- jpa自定义条件分页查询
主要依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sp ...
- Having用法
HAVING 子句对 GROUP BY 子句设置条件的方式与 WHERE 和 SELECT 的交互方式类似.WHERE 搜索条件在进行分组操作之前应用:而 HAVING 搜索条件在进行分组操作之后应用 ...
- Spring+Mybatis+SpringMVC后台与前台分页展示实例
摘要:本文实现了一个后台由spring+Mybatis+SpringMVC组成,分页采用PageHelper,前台展示使用bootstrap-paginator来显示效果的分页实例.整个项目由mave ...
- mysql 全表扫描、全索引扫描、索引覆盖(覆盖索引)
full index scan:全索引扫描,查询时,遍历索引树来获取数据行.如果数据不是密集的会产生随机IO 在执行计划中是Type列,index full table scan:通过读物理表获取数据 ...
- wikioi 1306 机智Trie树
题目描写叙述 Description 看广播操无聊得非常~你有认为吗?在看广播操一波又一波的人潮涌过再退去.认为非常没意思--于是,偶们的大神犇JHT发明了一个及其好玩的游戏~ 把每一班级的队形看成一 ...
- [HEOI2016/TJOI2016] 排序 解题报告(二分答案/线段树分裂合并+set)
题目链接: https://www.luogu.org/problemnew/show/P2824 题目描述: 在2016年,佳媛姐姐喜欢上了数字序列.因而他经常研究关于序列的一些奇奇怪怪的问题,现在 ...
- BZOJ 3339 线段树
思路: 考虑离线处理 显然 l固定时 r越大 ans越大 那我们不妨按照l从小到大排序 l->l+1的时候 l到next[l]这段区间都跟a[l]取min就好了 搞颗线段树维护一下 //By S ...
- Ubuntu下gcc安装
在Ubuntu下安装GCC和其他一些Linux系统有点不一样. 方法一: 该方法超简单:sudo apt-get build-depgcc 就上面这条命令就可以搞定 方法二:sudo apt-get ...
- spark thrift server configuration
# MainApplicationProperties # --master yarn --deploy-mode client 下的配置, client 模式表示,driver 是在本地机器上跑的, ...
- 固定执行计划-使用coe_xfr_sql_profile
一.历史执行计划固定 历史的执行计划找到一个合理的执行计划进行绑定 1. 存在多个执行计划的语句,按照索引是比较合适的,FULL SCAN不合适 select * from scott.emp whe ...