Uva-11384-help is needed for Dexter (law!! )

Source: Internet
Author: User

UVA-11384

Help are needed for Dexter
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &%llu

Submit Status

Description

Problem H

Help are 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 she's quite easy-to-play but isn't easy-to-win at least don't for Dee Dee. But Dexter does not has time to spend on this silly task, so he wants your help.

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

For example if N = 3, then on screen there'll 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 would be:0, 1, 3. Then she selects 1 and 3 and Commands to subtract 1. Now the numbers is 0, 0, 2. Now she subtracts 2 from 2 and all the numbers become 0.

Dexter is isn't so dumb to understand the This can be do very easily, so-make a twist he'll give a limit L for each N and surely L'll be as minimum as possible so it's still possible to win within L moves. But Dexter does not has time to think how to determine L for each n, so he asks you to write a code which would 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 would 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

Source

Root:: Prominent problemsetters:: Md. Mahbubul Hasan
Root:: AOAPC i:beginning Algorithm Contests--Training Guide (Rujia Liu):: Chapter 1. Algorithm Design:: General Problem Solving Techniques:: Examples
Root:: Competitive programming 3:the New Lower Bound of programming contests (Steven & Felix Halim):: Mathematics: : Ad Hoc Mathematics problems:: Logarithm, exponentiation, Power




Before the end of the final water,, the recent may be due to review the suspension of AC tour


Idea: Find the law, f [n] = f [N/2] + 1;


AC Code:






Uva-11384-help is needed for Dexter (law!! )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.