uva 11636
#include <cstdio>
#include <cstring>
#include <iostream> using namespace std; int main()
{
int arry[] = {};
int now = ;
for(int i = ; i <= ; ++i)
{
now *= ;
arry[i] = now;
//printf("%d\t", arry[i]);
}
int t, casee = ;
//while(scanf("%d", &t) != EOF && (t > 0))
while(scanf("%d", &t) != EOF && (t > ))
{
for(int i = ; i <= ; ++i)
{
if(t == )
{
printf("Case %d: %d\n", casee++, );
break;
}
else if(t <= arry[i] && t > arry[i-])
{
printf("Case %d: %d\n", casee++, i);
}
}
}
}
Hello World!
Input: Standard Input
Output: Standard Output
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.
Figure 1 |
Figure 2 |
Figure3 |
Figure 4 |
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 Output for Sample Input
2 10 -1 |
Case 1: 1 Case 2: 4 |
uva 11636的更多相关文章
- UVA.11636 Hello World! (思维题)
UVA.11636 Hello World! (思维题) 题意分析 这题挺水的,还是错了几发. QWQ. 有一个同学打了一行hello world,现在他想打n行hello world,请问最少复制粘 ...
- 贪心水题。UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing
UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r ...
- UVa 11636 - Hello World! 二分,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 11636 (注意读题) Hello World!
这道题巨坑啊,样例中以-1结束输入的,所以我就天真的以为测试数据也是以-1结束输入的 其实人家原文中说: Input is terminated by a line containing a nega ...
- UVA 11636 - Hello World! 水
水题,贪心,dp都随意 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,ple ...
- UVA - 11636 Hello World! (贪心)
思路:复制次数最少并且可以部分复制,那么贪心地让当前尽量多的复制,如果最后一次复制会超过n,那就部分复制.即满足并且x尽量小. AC代码 #include <stdio.h> const ...
- uva 11636 Hello World!
https://vjudge.net/problem/UVA-11636 题意: 希望输出n条语句,但是并不会循环,所以只能复制粘贴,一条语句经过复制粘贴后可以变为2条,2条变成4条....每次可以只 ...
- 贪心,打表(或者快速幂), UVA - 11636
题目链接: https://cn.vjudge.net/problem/34398/origin 题目比较简单,就是水题,基础贪心,大于所需的即可: AC代码: 打表: #include <cm ...
- UVa 11636 你好 世界!(贪心)
https://vjudge.net/problem/UVA-11636 题意: 经过一次复制,一条语句会变成两条语句,再经过一次变成四条语句...求最少需要复制几次能使条数恰好为n? 思路: 贪心水 ...
随机推荐
- Android ArrayAdapter使用
1. 可以直接使用getContext()获取Context对象 2. 可以在构造方法中传入context, 数据对象的列表, super(context, 0, object);完成Adapter的 ...
- 自定义Log模块
BuildConfig.DEBUG默认为true,在为app打上SignedKeyStore之后就为false, // Log控制器 MyLoger.openDebutLog(true); MyLog ...
- Linux 压缩系列常用命令
tar 命令: http://man.linuxde.net/tar zip 命令: http://man.linuxde.net/zip unzip 命令: http://man.linuxde.n ...
- LR结果分析——TPS和吞吐率
针对吞吐率和TPS的关系,这个在结果分析中如何使用,就个人经验和朋友讨论后,提出如下建议指导,欢迎同僚指正. TPS:transaction per second 服务器每秒处理的事务数. 吞吐率:测 ...
- HTML5 – 2.新元素
figcaption 定义和用法 <figcaption> 标签定义 figure 元素的标题(caption). "figcaption" 元素应该被置于 " ...
- Java集合源码学习(二)ArrayList分析
>>关于ArrayList ArrayList直接继承AbstractList,实现了List. RandomAccess.Cloneable.Serializable接口,为什么叫&qu ...
- Delphi版本顺序
1.02.03.04.05.06.07.08.0200520062007 现在应该又出新的版本了
- Delphi编译dll时出错"Cannot debug project unless a host application is defined.use the run|parameters...dialog box."
问题: 在编写DLL程序的时候,按下F9或者按下那个绿色的箭头,会报错,如下 原因: 是因为你按下的F9或者那个绿色箭头是表示“Run”这个程序,但是DLL不是可执行文件,所以当然不能够运行,所以就会 ...
- 你可能不知道的java、python、JavaScript以及jquary循环语句的区别
一.概述 java循环语句分为四种形式,分别是 while, do/while, for, foreach: python中循环语句有两种,while,for: JavaScript中循环语句有四种, ...
- [LeetCode] Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...