Uvalive 6084 Happy Camper (Maths problem)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.