UVA11636-Hello World!

Time limit: 1.000 seconds

When you first made the computer to print the sentence “Hello World!”, you felt so happy, not knowing how complex and interesting the world of programming and algorithm will turn out to be. Then you did not know anything about loops, so to print 7 lines of “Hello World!”, you just had to copy and paste some lines. If you were intelligent enough, you could make a code that prints “Hello World!” 7 times, using just 3 paste commands. Note that we are not interested about the number of copy commands required. A simple program that prints “Hello World!” is shown in Figure 1. By copying the single print statement and pasting it we get a program that prints two “Hello World!” lines. Then copying these two print statements and pasting them, we get a program that prints four “Hello World!” lines. Then copying three of these four statements and pasting them we can get a program that prints seven “Hello World!” lines (Figure 4). So three pastes commands are needed in total and Of course you are not allowed to delete any line after pasting. Given the number of “Hello World!” lines you need to print, you will have to find out the minimum number of pastes required to make that program from the origin program shown in Figure 1.


Input
The
input file can contain up to 2000 lines of inputs. Each line contains an
integer N (0 < N < 10001) that denotes the number of “Hello
World!” lines are required to be printed. Input is terminated by a line containing a negative integer.
Output
For
each line of input except the last one, produce one line of output of
the form ‘Case X: Y ’ where X is the serial of output and Y denotes the
minimum number of paste commands required to make a program that prints N
lines of “Hello World!”.
Sample Input
2

10

-1
Sample Output
Case 1: 1

Case 2: 4

题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2683

题目大意:给定n行,求要复制的次数!

分析:这样题意可能比较难理解,(我英文不太好)我是看样例猜答案的,输入的数很有规律,比如样例1,输入2,输出为1,我就这样想,2/2=1,很有道理,再看样例2,输入10,输出按照前面的想法应该是3才对啊,10/2=5,5/2=2,2/2=1->3,稍微拿脑袋想一想就知道不对了,如果向上取整的话是不是就是正解呢,样例1->(2+1)/2=1,样例2->(10+1)/2=5,(5+1)/2=3,(3+1)/2=2,(2+1)/2=1,刚好就等于4,输入小于0的数进行特判即可,于是我就进行了大胆的猜测题意:输入的数每次进行向上取整,求这个数需要经过多少次才能变成1!

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
int p=;
while(scanf("%d",&n)!=EOF)
{
if(n<)
break;
int ans=;
while(n>)
{
ans++;
n=(n+)/;
}
printf("Case %d: %d\n",p++,ans);
}
return ;
}

UVA 11636-Hello World!(水题,猜结论)的更多相关文章

  1. UVA 11636.Hello World!-水题

    Hello World! Time limit: 1.000 seconds When you first made the computer to print the sentence “Hello ...

  2. UVA.11636 Hello World! (思维题)

    UVA.11636 Hello World! (思维题) 题意分析 这题挺水的,还是错了几发. QWQ. 有一个同学打了一行hello world,现在他想打n行hello world,请问最少复制粘 ...

  3. UVa 1339 Ancient Cipher --- 水题

    UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...

  4. UVa 1225 Digit Counting --- 水题

    UVa 1225 题目大意:把前n(n<=10000)个整数顺次写在一起,12345678910111213...,数一数0-9各出现多少字 解题思路:用一个cnt数组记录0-9这10个数字出现 ...

  5. UVa 1586 Molar mass --- 水题

    UVa 1586 题目大意:给出一种物质的分子式(不带括号),求分子量.本题中分子式只包含4种原子,分别为C.H.O.N, 原子量分别为12.01,1.008,16.00,14.01 解题思路:先实现 ...

  6. UVa 272 Tex Quotes --- 水题

    题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Q ...

  7. UVa 1583 Digit Generator --- 水题+打表

    UVa 1583 题目大意:如果x加上x的各个数字之和得到y,那么称x是y的生成元. 给定数字n,求它的最小生成元 解题思路:可以利用打表的方法,提前计算出以i为生成元的数,设为d,并保存在a[d]中 ...

  8. UVa 1584 Circular Sequence --- 水题

    UVa 1584 题目大意:给定一个含有n个字母的环状字符串,可从任意位置开始按顺时针读取n个字母,输出其中字典序最小的结果 解题思路:先利用模运算实现一个判定给定一个环状的串以及两个首字母位置,比较 ...

  9. UVa 10970 - Big Chocolate 水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  10. UVa 12342 Tax Calculator (水题,纳税)

    今天在uva看到一个水题,分享一下. 题意:制定纳税的总额,有几个要求,如果第一个180000,不纳,下一个300000,纳10%,再一个400000,纳15%,再一个300000,纳20%,以后的纳 ...

随机推荐

  1. getchar() 、 scanf() 、流与缓冲区

    C中的缓冲区一直是debug的重灾区,今天在写一个命令行界面的时候又遇到了这个问题,所以来总结一波. 两函数的不同之处 scanf() 会把 stdinBuff 中的特定格式数据取出,非特定格式数据则 ...

  2. 学习ABP ASP.NET Core with Angular 环境问题

    1. 前言 最近学习ABP架构 搭建ASP.NET Core with Angular遇到了些问题,折腾了一个礼拜最终在今天解决了,想想这个过程的痛苦就想利用博客记录下来.其实一直想写博客,但因为 时 ...

  3. DeepLearning.ai学习笔记汇总

    第一章 神经网络与深度学习(Neural Network & Deeplearning) DeepLearning.ai学习笔记(一)神经网络和深度学习--Week3浅层神经网络 DeepLe ...

  4. bzoj 3192: [JLOI2013]删除物品

    Description   箱子再分配问题需要解决如下问题:  (1)一共有N个物品,堆成M堆.  (2)所有物品都是一样的,但是它们有不同的优先级.  (3)你只能够移动某堆中位于顶端的物品.  ( ...

  5. dotnet core 自定义配置文件

    首先添加一个.json 文件,比如 setting.json 文件内容如下,记得把文件设置为“复制到输出目录” { "ConfigSetting": { "XXXName ...

  6. grpc

    grpc入门(二) 一. 目标 本博文要介绍的是编写 grpc入门(一)中所提到的四种rpc的方式,然后通过命令行和eclipse两种方式生成对应的java代码,关于grpc是什么东西本文不再赘述. ...

  7. IDEA第八章----远程调试

    大家有没有遇到相同分支的代码在本地就是没有问题的,但是到测试环境死活不能实现功能,且还不报错.通常我们的解决办法就是打日志,然后一点一点跟踪日志. 这时我们在想如果也可以按照本地一样能断点测试的程序就 ...

  8. Wechat 微信端正确播放audio、video的姿势

    在开发微信项目时,有在项目中播放音频(audio)和视频(video)的需求: 在开发中,我们会遇到的问题 audio.video在Android和IOS系统上的兼容性: video播放完成后,跳出浏 ...

  9. C#Winform使用mysql作为本地数据库

    MYSQL是老牌关系型数据库,在受够了sqlite,mslocaldb,sqlce等本地数据库之后,发现了mysql5.6的一些版本也可以绿色安装,编程实现从资源文件里面解压到目标机器上,并配置好成为 ...

  10. git应用套路

    git应用套路 一. 配置git别名 1.通过控制台命令vim ~/.gitconfig打开配置页面 2.配置如下内容: [user] name = your Name email = your E- ...