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_ ...
随机推荐
- SpringBoot+Maven聚合多项目打包成jar
已我最近自己在玩的一个DEMO为例 taosir为pom.xml,其他子项目均为其modules,且为jar项目 eureka为注册中心.workflow为提供者.entrance为调用方 entra ...
- STM32使用HAL库实现ADC单通道转换
STM32的ADC转换还是很强大的,它具有多个通道选择,这里我就不细说,不了解的可以自行百度,这里只是选取单通道,实现ADC转换.在文章开始之前,我说一下数据左对齐跟右对齐的差别,以前一直糊里糊涂的, ...
- GitHub上搭建私人hexo博客操作教程
GitHub上搭建hexo博客 安装GitGit:主要用于上传博客页面到github和命令操作安装NodeNode.js:Hexo的运行环境安装HexoHexo:博客程序打开安装Git后的生成的右键菜 ...
- 基本配置及安全级别security-level
interface GigabitEthernet0/0 nameif outside //指定接口名称 security-level 0 //安全级别设置 ip address 1.1.1.2 ...
- 2015 Multi-University Training Contest 7 hdu 5372 Segment Game
Segment Game Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- GROUP BY 与聚合函数 使用注意点
表的设计: 表里面的内容: 一:在不使用聚合函数的时候,group by 子句中必须包含所有的列,否则会报错,如下 select name,MON from [测试.] group by name 会 ...
- iOS UI16_数据持久化
// // Student.h // UI16_数据持久化 // // Created by dllo on 15/8/19. // Copyright (c) 2015年 zhozhicheng. ...
- 拷贝构造函数不能传值,只能传引用,而且一般是传const引用
为什么呢?因为传值函数,需要调用拷贝构造函数,那就层层循环无止境了.
- HDU 4307 Contest 1
http://www.cnblogs.com/staginner/archive/2012/08/13/2636826.html 自己看过后两周吧,重新写了一遍.很受启发的.对于0.1,可以使用最小割 ...
- 110_leetcode_Best Time to Buy and sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...