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? 思路: 贪心水 ...
随机推荐
- Jpinyin笔记
- mysqli扩展库的预处理技术 mysqli stmt
//预编译演示 //1,创建mysqli对象 $mysqli=new mysqli("localhost","root",""," ...
- Python中如何读取xml的数据
<?xml version="1.0" encoding="utf-8" ?> - <catalog> <maxid>4&l ...
- Android Programming: Pushing the Limits -- Chapter 2: Efficient Java Code for Android
Android's Dalvik Java 与 Java SE 进行比较 Java代码优化 内存管理与分配 Android的多线程操作 Android’s Dalvik Java 与 Java SE ...
- (2)Underscore.js常用方法
目录 1.集合相关方法 1.1.数组的处理 map(循环,有返回值),将返回的值依次存入一个新的数组 each(循环,无返回值 ...
- Pyqt 获取windows系统中已安装软件列表
开始之前的基础知识 1. 获取软件列表 在Python的标准库中,_winreg可以操作Windows的注册表.获取已经安装的软件列表一般是读去windows的注册表: SOFTWARE\Micros ...
- AngularJS 之 Factory、Service、Provider
当你初试 Angular 时,很自然地就会往 controller 和 scope 里堆满不必要的逻辑.一定要早点意识到,controller 这一层应该很薄:也就是说,应用里大部分的业务逻辑和持久化 ...
- AndroidStudio创建新项目报错
创建新项目自动执行时报错: Failed to import new Gradle project: failed to find Build Tools revision 17.0.0 Consul ...
- [Linux] 解决终端显示乱码问题
[背景] 公司弄了两台新的虚拟机,用来将原先都部署在一台机器上的JIRA, Fisheye, Confluence迁移到这两台机器上,使用SecureCRT进行登录,使用相关命令时,一台出现乱码,另外 ...
- servlet、genericservlet、httpservlet之间的区别
转自:http://blog.csdn.net/rat9912345/article/details/5161789 当编写一个servlet时,必须直接或间接实现servlet接口,最可能实现的方法 ...