UVALive 6084 Happy Camper(数学题)
2014-07-20 21:53
429 查看
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4095
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
代码如下:
----------------------------------------------------------------------------------------------------------------------------------------------------------
欢迎光临天资小屋 :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(数学题)
- UVALive 7040 Color 容斥原理 + 组合数学递推公式 +lucas
- UVaLive 6628 Grachten (水题,数学)
- UVALive 5070 Awkward Lights 数学 高斯消元
- UVALive2362 POJ1004 HDU1064 ZOJ1048 Financial Management【数学计算+水题】
- UVALive 7511 L - Multiplication Table 数学模拟题,暴力
- UVALive 3490 (LA 3940) || ZOJ 2619 Generator AC自动机(或KMP) + 整数高斯消元 + 数学期望
- The queue uvalive 5002 light 1382 uva 12257 (dfs加组合数学)
- UVaLive 7362 Farey (数学,欧拉函数)
- UVALive6929 Sums【数学】
- UVALive 6582 Magical GCD (数学+数据结构) -- 解题报告
- UVALive - 3485 Bridge 二分+数学+自适应辛普森求积分
- UVALive 7040 Color (容斥原理 + 组合数学递推公式 + 求逆元 + 基础数论)
- (UVALive - 7722)L - Tale of a Happy Man(DP)
- UVALive 5058 Counting BST 数学
- HDU1046 POJ1450 UVALive2334 ZOJ1037 Gridland【数学计算+水题】
- UVALive 6925 Volume of Revolution(数学题)
- UVALive2287 POJ1047 HDU1313 ZOJ1073 Round and Round We Go【大数+数学计算+水题】
- UVALive 3720 Highways 组合数学
- UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)