UVALive 6084 Happy Camper(数学题)

题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4095

----------------------------------------------------------------------------------------------------------------------------------------------------------
欢迎光临天资小屋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;
}
时间: 2024-08-09 06:19:45

UVALive 6084 Happy Camper(数学题)的相关文章

HDU5344——数学题——MZL&#39;s xor

MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to know the xor of all (Ai+Aj)(1≤i,j≤n)The xor of an array B is defined as B1 xor B2...xor Bn Input Multiple test cases, the first line contains an integer T(no more than 20

【算法编程】小学数学题难倒博士

昨天在科学网上得知这样一个新闻<越南小学数学题难倒博士>,据悉题目来自越南保禄小学三年班,不过报道称该题难倒了上至博士下至家长,未免也太言过其实了. 题目描述 学生需要在下图表格中按由上至下.从左到右的顺序,填入1~9的数字,可重复填写,并按先乘除后加减(图中冒号代表除法)的运算法则,完成整条算式. 解题方法 显然,这题对于我们这种程序员来说完全不是问题,只要在大一上过C语言的学生(我们学校全校都学过C,即使是文科专业)基本上都可以用九重for循环来穷举解出此题,下面我分别用C和Matlab实

UVALive 4848 Tour Belt

F - Tour Belt Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVALive 4848 Description Korea has many tourist attractions. One of them is an archipelago (Dadohae in Korean), a cluster of small islands sca

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

UVALive 6467 Strahler Order 拓扑排序

这题是今天下午BNU SUMMER TRAINING的C题 是队友给的解题思路,用拓扑排序然后就可以了 最后是3A 其中两次RE竟然是因为: scanf("%d",mm); ORZ 以后能用CIN还是CIN吧 QAQ 贴代码了: 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 #include <iostre

一道有趣的数学题

班主任给了我一道数学题: 求证an都能表示成两个自然数的平方和. [分析] 不会就打表(OI后遗症) 那么我们发现an的第2个平方在an+1出现在了第一个(按从小到大) 这个就很py了啊,再看看第二个有啥关系..咦好像是比两倍多一点,多多少呢?咦,1.3.7.17--这不就是我找的那个规律了吗 啊我们就能猜想: 然后我们归纳一波 对于n<=5显然成立(上表),对于n>=6: 假设对于n=i成立,那么就有 目标:证明下式成立 这是啥呢?令A'=B,B'=A+2B,代入即可. 剩下的故事啊就是把递

一道很有意思的数学题

题目:某个家庭中有2个小孩,已知其中一个是女孩,则另一个是女孩的概率是多少? 答案:1/3 今天上概率课,想起了高中的这一道数学题.当初在高中对这个答案真的是百思不得其解,始终认为是1/2.生男生女和另一个孩子的性别有什么必然的联系吗?最后迫于升学的压力,不能任性啊~!!!只得背过答案,碰到前后性别不一样,就是2/3,一样就是1/3. 今天想起来,在百度上的找了好多关于这个问题理解,虽然有说1/3的,有说1/2的,但是仔细观察后发现,其实关于各种答案的问题描述还是有细微的差别的.最后在这里: 一

python笔记1-用python解决小学生数学题

前几天有人在群里给小编出了个数学题: 假设你有无限数量的邮票,面值分别为6角,7角,8角,请问你最大的不可支付邮资是多少元? 小编掰着手指头和脚趾头算了下,答案是:1.7元 那么问题来了?为啥是1.7呢,于是小编用python解决了这个小学数学题. 一.排列组合 假设6.7.8角各有50张(50张够了),先计算出所有的可能组合 二.排序.去重 先对组合就行排序,从小到大的顺序,排队站好,这里用到sort()函数(要是你用冒泡排序,那你就out啦!) sort函数只是对list序列排序,并没有返回

UVALive 7077 Little Zu Chongzhi&#39;s Triangles (有序序列和三角形的关系)

这个题……我上来就给读错了,我以为最后是一个三角形,一条边可以由多个小棒组成,所以想到了状态压缩各种各样的东西,最后成功了……结果发现样例过不了,三条黑线就在我的脑袋上挂着,改正了以后我发现N非常小,想到了回溯每个棍的分组,最多分5组,结果发现超时了……最大是5^12 =  244,140,625,厉害呢…… 后来想贪心,首先想暴力出所有可能的组合,结果发现替换问题是一个难题……最后T T ,我就断片了.. 等看了别人的办法以后,我才发现我忽视了三角形的特性,和把数据排序以后的特点. 如果数据从