Title Link: Https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem &problem=4095
--------------------------------------------------------------------------------------------------------------- -------------------------------------------
Welcome to Flair Lodge: Http://user.qzone.qq.com/593830943/main
--------------------------------------------------------------------------------------------------------------- -------------------------------------------
As Happy Camper Harry pulls into its favorite campground with his family, he notices the sign:
' Campground occupancy is limited to ten days within any consecutive 20-day period. ' Harry is just
Starting a 28-day vacation. What's 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 is integers. camp-
Ground occupancy is limited-L days within any consecutive p-day period. Happy Camper Harry
is just starting a V-Day vacation. What's the maximum number of days he can occupy a campsite
During his vacation?
Input
The input would contain data for a number of test cases. For each test case, there'll be a line of data,
Containing values of L, P and V, in that order. All input integers can is represented by signed 32-bit
Integers. End of data would be signaled to a line containing three zeros, which would not be processed.
Output
There would be a line of output for each test case. It would 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
The code is as follows:
#include <stdio.h> #define LL long Longint 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++);p rintf ("%lld\n", ans);} return 0;}
Uvalive 6084 Happy Camper (Maths problem)