vijos-p1385 theft-Eye of the Moon (water + python)

Source: Internet
Author: User

P1385Stealing-the eye of the moon accepted Tags: Monster thief kidd VS oibh[display tag]<textarea id="code" class="textbox"></textarea>Background

Blame theft Kidd VS Oibh
Third words

Descriptive narrative

This is the third time that I have come to the familiar OIBH headquarters. The oibh of the eye of Moon, who repeatedly failed. Or that?
Room. Or the door, the difference is that the OIBH has improved the password lock. This screen only shows a number n (Kidd: This is
Improved or degraded? )。

Password Generation method: Set a={1,2,..., n} in set a. B is a subset.

For a random element in B, x,2x is not in set B.

The maximum number of elements in B is password.

Format input Format

One line, an integer n (1<=n<=maxlongint)

Output format

There is only an integer m. Represents the element's maximum value in B

Example 1 example input 1[copy]
100
Example output 1[copy]
67
Limit

Oibh will be found within 6s, so every point just has 1s time for you

Tips

Simple math Problem Oh ~ ~

Source

From Maiev-The song of the Shadow;
Thanks to Vijos's friends for providing data

For long long, we can't do this with a traversal method, only by writing a set of equations about N to solve the problem.

Through the topic we can find

Suppose I go to 50 people in 51-100. Must be eligible.

I went to 13-24 in the 13 people are still eligible, so, constantly push down. Add up all the qualifying numbers and you'll be able to


#!/usr/bin/env python3#-*-coding:utf-8-*-def Fun (n):    if n = = 1:return 1    if n = = 0:return 0    ans = fun (n/2 /2)    ans + = n-n/2    return ansimport mathn = Int (raw_input ()) print fun (n)        


vijos-p1385 theft-Eye of the Moon (water + python)

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.