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_ ...
随机推荐
- echarts 柱状图和饼状图动态获取后台数据
运用echarts来实现图表 1.首先下载echarts包 http://echarts.baidu.com/echarts2/doc/example.html,在这里我下载的是 2.将echart ...
- HDU 1709
MB,一开始就想到是不是只要加上一个不选择砝码的情况,但一直没动手做,因为看了看网上了,觉得总有点复杂,认为自己想错了.... 相信自己 #include <iostream> #incl ...
- Android学习之GridView图片布局适配经验
開始解说这篇博客之前,我想问一下,当布局相似GridView这样的多列布局时,我们该怎么布局,才干更好的去适配呢? 扣张图来展示一下 比如这样的需求,三张图片均分屏幕 实现方法: 1.切图固定,比如是 ...
- 【BZOJ3270】博物馆 概率DP 高斯消元
链接: #include <stdio.h> int main() { puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网 ...
- [Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
使用Hibernate官方文档上的下面代码进行測试时报出这个异常. org.hibernate.HibernateException: Access to DialectResolutionInfo ...
- ioctl.h 分析
ioctl.h 分析 我自己画了个解析图...不要嫌弃丑啊.. . 哈哈 type The magic number. Just choose one number (after consulting ...
- python解压,压缩,以及存数据库的相关操作
zipfile实现压缩整个目录和子目录 import os,shutil,zipfile,glob def dfs_get_zip_file(input_path,result): # files = ...
- bzoj1212: [HNOI2004]L语言(字典树)
1212: [HNOI2004]L语言 题目:传送门 题解: 看完题目之后就觉得可以暴力在字典树上之间询问,一开始还傻了以为用文章来建,肯定用单词啊: 那么我们可以用一个v数组表示当前字符串1~i的区 ...
- mysql实战45讲读书笔记(一) 一条SQL查询语句是如何执行的
我们经常说,看一个事儿千万不要直接陷入细节里,你应该先鸟瞰其全貌,这样能够帮助你从高维度理解问题.同样,对于MySQL的学习也是这样.平时我们使用数据库,看到的通常都是一个整体.比如,你有个最简单的表 ...
- localStorage、sessionStorage的区别
1.localStorage生命周期是永久的, sessionStorage生命周期为当前窗口或标签页,一旦窗口或标签页被永久关闭了,那么所有通过sessionStorage存储的数据也就被清空了. ...