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_ ...
随机推荐
- python课堂知识的几点总结
1.执行python脚本的两种方式:利用python进入解释器和找到可执行文件1.py 2.位和字节:一个字节是8位,计算机运行时是以字节为单位,存储的时候是以位为单位 3.编码发展:ASCII只有0 ...
- [luogu] P2354 [NOI2014]随机数生成器 (贪心)
Description Input 第1行包含5个整数,依次为 x_0,a,b,c,d ,描述小H采用的随机数生成算法所需的随机种子.第2行包含三个整数 N,M,Q ,表示小H希望生成一个1到 N×M ...
- 数据库ifnull方法
IFNULL(expr1,expr2)如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2.IFNULL()返回一个数字或字符串值.例如: ifnull() 如果sum(t ...
- codevs 1803 志愿者招募
1803 志愿者招募 2008年NOI全国竞赛 时间限制: 2 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 申奥成功后,布布经过不懈努 ...
- 简单谈谈MySQL优化利器-慢查询
慢查询 首先,无论进行何种优化,开启慢查询都算是前置条件.慢查询机制,将记录过慢的查询语句(事件),从而为DB维护人员提供优化目标. 检查慢查询是否开启 通过show variables like ' ...
- spring-boot-maven-plugin 插件的作用(转)
OM 文件中添加了“org.springframework.boot:spring-boot-maven-plugin”插件.在添加了该插件之后,当运行“mvn package”进行打包时,会打包成一 ...
- Ruby中写换行
Ruby中写换行 print("Hello,\nRuby\n!\n") print("Hello, Ruby ! ") 这两个竟然是一样的:就是说,可以直接回车 ...
- 搜狗面试的经典题(C++map按值排序,class struct的差别)
一:起因 (1)java Map排序(key,value).请看还有一篇博客 java Map排序 (2)c++ map排序(key,value),能够对c++ map和java Map进行对照:之 ...
- 设计网页录入信息与自己定义server数据接收
需求:设计一个注冊网页用于录入username和登录password.并将数据传入server并显示出来. 1.前言:网页提交的 get 和 post 两种方式. (1)对于get提交方式,以本文中样 ...
- NOIP2017提高组模拟赛 9 (总结)
NOIP2017提高组模拟赛 9 (总结) 第一题 星星 天空中有N(1≤N≤400)颗星,每颗星有一个唯一的坐标(x,y),(1≤x,y ≤N).请计算可以覆盖至少K(1≤K≤N)颗星的矩形的最小面 ...
