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)