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

问题链接:UVA11636 Hello World!

问题简述

开始的时候只有1行,对于输入的n,问需要几次拷贝就能把1行拷贝成n行。

问题分析

一次一次模拟就好。

如果把所有都拷贝下来则拷贝速度最快,有点像贪心法,实际应该是模拟。

程序说明:(略)

题记

不会做就枚举,再不会做就模拟。

参考链接:(略)

AC的C++语言程序如下:

/* UVA11636 Hello World! */#include <bits/stdc++.h>using namespace std;int main()
{int n, caseno = 0;while(~scanf("%d", &n) && n > 0) {int cnt = 1, ans  = 0;while(cnt < n) {ans++;cnt <<= 1;}printf("Case %d: %d\n", ++caseno, ans);}return 0;
}

UVA11636 Hello World!【模拟】相关推荐

  1. springboot实现SSE服务端主动向客户端推送数据,java服务端向客户端推送数据,kotlin模拟客户端向服务端推送数据

    SSE服务端推送 服务器向浏览器推送信息,除了 WebSocket,还有一种方法:Server-Sent Events(以下简称 SSE).本文介绍它的用法. 在很多业务场景中,会涉及到服务端向客户端 ...

  2. curl模拟post请求

    另外可尝试 postman工具 或者用request 直接请求 CURL 发送POST请求curl -header "Content-Type: application/json" ...

  3. flask_模拟请求post,get

    #coding:utf-8 import requestsres = requests.post(url="http://192.168.135.105:8888/",data={ ...

  4. 模拟内存计算如何解决边缘人工智能推理的功耗挑战

    模拟内存计算如何解决边缘人工智能推理的功耗挑战 How analog in-memory computing can solve power challenges of edge AI inferen ...

  5. 为放大器模拟输入模块提供可靠的输入过电压保护

    为放大器模拟输入模块提供可靠的输入过电压保护 Signal Chain Basics #159: Provide robust input overvoltage protection for amp ...

  6. 模拟Servlet本质

    JavaWeb系列教程,持续更新 JavaWeb-Servlet 模拟Servlet本质 使用IDEA开发Servlet程序 Servlet对象的生命周期 适配器(GenericServlet)改造S ...

  7. 2021年大数据Flink(四十):​​​​​​​Flink模拟双十一实时大屏统计

    目录 Flink模拟双十一实时大屏统计 需求 数据 编码步骤: 1.env 2.source 3.transformation 4.使用上面聚合的结果,实现业务需求: 5.execute 参考代码 实 ...

  8. Python:模拟登录、点击和执行 JavaScript 语句案例

    案例一:网站模拟登录 # douban.pyfrom selenium import webdriver from selenium.webdriver.common.keys import Keys ...

  9. 杨老师课堂_Java核心技术下之控制台模拟文件管理器案例

    背景需求介绍: 编写一个模拟文件管理器的程序,实现控制台对文件和文件夹的管理操作. 要求在此程序中: 当用户输入指令 1 时,代表"指定关键字检索文件",此时需要用户输入检索的目录 ...

最新文章

  1. leetcode算法题--最后一块石头的重量 II★
  2. laravel使用redis做缓存的方法
  3. python画椭圆turtle_如何用Python画一只肥肥的柯基狗狗——turtle库绘制椭圆与弧线实践...
  4. mysql全局变量之max_connections max_user_connections详解
  5. 伴鱼:借助 Flink 完成机器学习特征系统的升级
  6. ibm nvidia 超级计算机,IBM,Nvidia和美国能源部组成一个超级计算机超级团队
  7. PHP相等(==双重等于)和标识(===三次等于)比较运算符有何区别?
  8. Maximum Mode
  9. C#并发编程实例讲解-概述(01)
  10. SublimeText 3 高亮 MATLAB语法
  11. 0x800704cf 共享打印机_0x800704cF,详细教您Win7访问共享时提示错误0x800704cf怎么办
  12. 链路追踪Logback-ERROR日志邮件发送
  13. PC软件-实用工具 True Launch Bar
  14. MYS-6ULX-IOT 开发板测评——使用 Yocto 添加软件包
  15. rdkit smiles支持和扩展
  16. 励志故事:拥有一颗热忱之心
  17. visual studio和vs code 哪个好用,适用于哪个阶段
  18. vue 屏幕自适应及全屏放大缩小
  19. centos php-fpm 位置,centos 如何安装 php-fpm
  20. java学习之服务器第26天( --form表单-- 四大域对象--cookie)

热门文章

  1. 容器大小_C++复习篇(7)序列式容器vector
  2. ArcGIS——vs2015安装arcgis engine不兼容
  3. chrome jsp 显示不正常_selenium+java谷歌浏览器 网站打开不正常
  4. vim写python_用 Vim 写 Python 的最佳实践
  5. 武汉大学计算机学院创业老师,胡瑞敏 - 教师简历 CV- 武汉大学计算机学院
  6. 字母大小写全排列C语言,14种模式解决面试算法编程题(PART II)
  7. dubbo 服务压测_不可忽视的Dubbo线程池
  8. 信息系统开发与管理(自考)往届题目复习
  9. 科恒khs202温控器使用说明书_STC-9200温控器使用说明书——精创温控器
  10. JFinal(一)JFinalConfig