Help is needed for Dexter

2024-08-29 01:38
文章标签 help needed dexter

本文主要是介绍Help is needed for Dexter,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


             原文请访问我的博客   http://xiaoshig.sinaapp.com/

Description

Download as PDF

Problem H

Help is needed for Dexter

Time Limit: 3 Second

 

Dexter is tired of Dee Dee. So he decided to keep Dee Dee busy in a game. The game he planned for her is quite easy to play but not easy to win at least not for Dee Dee. But Dexter does not have time to spend on this silly task, so he wants your help.

 

There will be a button, when it will be pushed a random number N will be chosen by computer. Then on screen there will be numbers from 1 to N. Dee Dee can choose any number of numbers from the numbers on the screen, and then she will command computer to subtract a positive number chosen by her (not necessarily on screen) from the selected numbers. Her objective will be to make all the numbers 0.

 

For example if N = 3, then on screen there will be 3 numbers on screen: 1, 2, 3. Say she now selects 1 and 2. Commands to subtract 1, then the numbers on the screen will be: 0, 1, 3. Then she selects 1 and 3 and commands to subtract 1. Now the numbers are 0, 0, 2. Now she subtracts 2 from 2 and all the numbers become 0.

 

Dexter is not so dumb to understand that this can be done very easily, so to make a twist he will give a limit L for each N and surely L will be as minimum as possible so that it is still possible to win within L moves. But Dexter does not have time to think how to determine L for each N, so he asks you to write a code which will take N as input and give L as output.

 

Input and Output:

Input consists of several lines each with N such that 1 ≤ N ≤ 1,000,000,000. Input will be terminated by end of file. For each N output L in separate lines.

 

SAMPLE INPUT

OUTPUT FOR SAMPLE INPUT

1

2

3

1

2

2

 

Problemsetter: Md. Mahbubul Hasan

[Submit]   [Go Back]   [Status] 

#include<iostream>
using namespace std;
int main()
{int n,i;while(cin>>n){for(i=0;n!=0;i++){n=n/2;}cout<<i<<endl;}return 0;
}


这篇关于Help is needed for Dexter的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1116475

相关文章

HDU 1712 ACboy needs your help (分组背包)

OJ题目:click here~~ 题意分析:分组背包入门题。N个课程,最多可使用M天的时间。给出i课程用j天所获得的profit 。 求最多使用M天的最大profit。对课程i ,1--M天的profit 只能选一个,或者不选。也就是说有的课程不上也没有关系。明显的分组背包。 AC_CODE int x[101][101];int main(){int n , m;while(c

默默的学python——两个重要的函数dir()、help()

一、dir()函数 dir()函数在Python中用于返回一个对象的所有属性和方法的列表,当你对一个函数使用dir()时,它会返回函数对象的所有可访问的属性和方法的名字列表。 具体的说,dir()函数获取的内容包括: 1.特殊方法和魔法方法 如 call、code、defaults、doc、globals、__name__等,这些方法和属性是函数对象的一部分,提供了对函数元数据的访问。

第一个golang项目增加help指令并调整指令模式

第一个golang项目增加help指令并调整指令模式 调整指令模式增加help指令减少了配置文件的解析读取次数新指令模式打包并运行 上一篇文章 调整指令模式 version指令修改为-v和-versionreplace指令修改为-r和-replacedir参数修改为-d和 -directory package commandsimport ("flag""fmt""lo

Command line option syntax error.type Command /? for help

电脑装思维导图的时候,报错显示“Command line option syntax error.Type Command /? for help.”就查了一下,原来是系统没有C++2005,需要安装,就上网下载了一个vcredist_x86.exe,但是双击安装,仍然出现这个错误。 没办法,接着上网查吧,是什么原因呢?网上说是因为该文件安装不支持中文安装路径,然后我就把文件夹改成了英文名称

Help with Intervals 线段树并查集

Time Limit: 6000MS Memory Limit: 131072KTotal Submissions: 9784 Accepted: 2320Case Time Limit: 2000MS Description

npm error network ‘proxy‘ config is set properly. See: ‘npm help config‘

使用" npm install " 或者 "  npm i " 初始化项目依赖失败 npm error network 'proxy' config is set properly. See: 'npm help config' 出现这样的解决方法如下:  1.查看代理 //代理npm config get proxy //缓存npm config get npm confi

Git报错git: ‘remote-http‘ is not a git command. See ‘git --help‘

目录 一、问题描述二、解决方法 一、问题描述 CentOS 7 下执行 git clone http://xxxx 命令时报错,Git 版本为 2.35.1 : git: 'remote-http' is not a git command. See 'git --help' 二、解决方法 安装 libcurl-devel、curl-devel ,然后重新编译 git

登陆Oracle EBS的Form遇到问题Internet Explorer has modified this page to help prevent cross-site scripting

登陆Oracle EBS的Form遇到问题Internet Explorer has modified this page to help prevent cross-site scripting         今天在登陆Oracle EBS的Form 遇到问题Internet Explorer has modified this page to help prevent cross-site

解决go build报错cannot find main module; see 'go help modules'

描述: 在学习golang的过程中,在$GOPATH/src/github.com/xxx/hello目录下执行go build和go test都会报下面的错误 go: cannot find main module; see ‘go help modules’ 解决方案: 由于之前设置过GO111MODULE=on,所以使用下面的命令解决 $ go mod init hello 生