LightOJ - 1241 Pinocchio

Time Limit: 500MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu

Status

Description

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

2

5

2 3 3 3 4

4

2 3 4 5

Sample Output

Case 1: 2

Case 2: 3

Source

Problem Setter: Jane Alam Jan

Status

这个人说谎鼻子会长长 1 --> 5cm, 给出一天中某时刻(严格升序)鼻子长度, 输出最少说几次谎;

#include <cmath>
#include <cstdio>
int main()
{
    int t, Q=1; scanf("%d", &t); 
    double a[100];
    while(t--)
    {
        int n; scanf("%d", &n);
        for(int i=0; i< n; i++)
            scanf("%lf", &a[i]);
        int cnt= 0;
        for(int i=1; i<n; i++)
        {
            if(a[i]!= a[i-1])
                cnt= cnt+ ceil((a[i]-a[i-1])/5); 
        }
        if(a[0]> 2)
        {
            cnt= cnt+ceil((a[0]-2)/5); 
        }
        printf("Case %d: %d\n", Q++, cnt);
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/soTired/p/5452863.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值