博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lightoj1241——Pinocchio (模拟+ceil)
阅读量:2344 次
发布时间:2019-05-10

本文共 3476 字,大约阅读时间需要 11 分钟。

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

Output for Sample Input

Case 1: 2

Case 2: 3

匹诺曹的鼻子每次增长1~5cm,给出一天的长度,求最少撒谎次数

别的没什么,主要是ceil只对double类型管用

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f#define MAXN 2005#define Mod 10001using namespace std;double a[20];int main(){ int t,cnt=1; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); for(int i=0;i
2) ans+=ceil((a[0]-2)/5); printf("Case %d: %d\n",cnt++,ans); } return 0;}

转载地址:http://npcvb.baihongyu.com/

你可能感兴趣的文章
c中int和long类型
查看>>
二维字符数组与字符串数组
查看>>
c中指针赋值为0
查看>>
c中求二维数组的行数和列数
查看>>
三目运算符跟赋值运算符的计算顺序
查看>>
elf文件与符号表
查看>>
linux net-snmp(之安装及配置)
查看>>
linux net-snmp(之android移植)
查看>>
linux net-snmp(之mib2c工具生成标量节点代码)
查看>>
linux net-snmp(之mib2c工具生成表格代码)
查看>>
扩展程序运行时的库路径
查看>>
【CUDA并行程序设计系列(4)】CUDA内存
查看>>
CPU、GPU、CUDA,CuDNN 简介
查看>>
U-boot如何引导Linux内核启动?
查看>>
程序各个段text,data,bss,stack,heap
查看>>
如何利用ROS MoveIt快速搭建机器人运动规划平台?
查看>>
catkin_make &catkin build
查看>>
Camera和IMU的标定过程之kalibr 源码编译
查看>>
在ubuntu下安装python的numpy和scipy模块
查看>>
Ubuntu下apt-get与pip安装命令的区别
查看>>