LightOJ 1241- Pinocchio【模拟】

1241 - Pinocchio
    PDF (English) Statistics Forum
Time Limit: 0.5 second(s) Memory Limit: 32 MB

You must have heard the name of Pinocchio. If you never heard of him, don't panic, I am here to help you. But why I am introducing you to Pinocchio? Cause there is an interesting (and also quite strange) fact about him.

Pinocchio is a boy who lives in a certain village. He is a little boy, who is prone to telling lies, fabricating stories and exaggerating or creating tall tales for various reasons. But the strange fact is, when he does this, his nose gets longer. But when he tells the truth his nose gets back to normal size which is 2 cm.

Usually, when he wakes up in the morning his nose gets back to normal size. When he tells a lie, his nose grows at least 1 cm and at most 5 cm.

              

Pinocchio                   Pinocchio after some lies

There is a common paradox related to him. What if he says, "My nose grows now." You may wonder why the simple looking statement leads to a paradox. The result of this deadly statement is noted below:

Assume that this sentence is true

1.      Which means that Pinocchio's nose grows now because he truthfully says it is, but then

2.      Pinocchio's nose does not grow now because it grows only as Pinocchio lies, but then

3.      Pinocchio's nose grows now because Pinocchio's nose does not grow now, and Pinocchio trustfully says it grows now, and it is false, that makes Pinocchio's sentence to be false, but then

4.      Pinocchio's nose does not grow now because Pinocchio's nose grows now, and Pinocchio trustfully says it grows now, and it is true that makes Pinocchio's sentence to be true, but then

5.      And so on ad infinitum.

 

Now assume that the sentence is false

1.      Which means that Pinocchio's nose does not grow now because he falsely says it is, but then

2.      Pinocchio's nose grows now because it grows only as Pinocchio lies, but then

3.      Pinocchio's nose does not grow now because Pinocchio's nose grows now, and Pinocchio falsely says it grows now, and it is false that makes Pinocchio's sentence to be true, but then

4.      Pinocchio's nose grows now because Pinocchio's nose does not grow now, and Pinocchio falsely says it grows now, and it is true, that makes Pinocchio's sentence to be false, but then

5.      And so on ad infinitum.

 

Now you are given some sizes of his nose in a day. Assume that he hasn't told any truth in that day and the sizes are reported in increasing order of time. You have to find the minimum number of lies he has told in that day such that the report of the sizes is true.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing an integer n (1 ≤ n ≤ 10), where n denotes the total number of reports of his nose in a certain day. The next line contains n space separated integers denoting the sizes of his nose in that day. If the integers in that line is a1, a2 ... an, you can assume that

(2 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 50)

Output

For each case, print the case number and the minimum number of lies Pinocchio has told in that day. See the samples for the output format.

Sample Input

Output for Sample Input

2

5

2 3 3 3 4

4

2 3 4 5

Case 1: 2

Case 2: 3

 

PROBLEM SETTER: JANE ALAM JAN
解题思路:
//题意:玩偶的鼻子初始的长度是2cm
玩偶的鼻子会因为说谎而变长,但是每说一次谎,它的鼻子最少增加1cm最多增加5cm,现在给你一天中n个时间点的鼻子的长度,问他最少说了几次谎。
//思路:
因为每次最多只能增长5cm,所以如果遇到1      10 这种情况,那么他最少说了两次谎。
#include<stdio.h>
#include<cmath>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	int ii=0;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		int ans=0,cnm=0;
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			int a;
			scanf("%d",&a);
			a-=2;
			if(a>cnm)
			{
				ans+=ceil((a-cnm)*1.0/5);
				cnm=a;
			}
		}
		printf("Case %d: %d\n",++ii,ans);
	}
	return 0;
} 


你可能感兴趣的:(模拟,lightoj)