UVa 701 The Archeologists ' dilemma: Mathematics and enumeration

Source: Internet
Author: User
Tags time limit

701-the Archeologists ' dilemma

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_ problem&problem=642

An archeologist seeking proof of the presence of extraterrestrials in the Earth ' s past, stumbles upon a partially Destroye D wall containing strange chains of numbers. The left-hand part of this lines of digits is always intact, but unfortunately the right-hand one was often lost by Erosio N of the stone. However, she notices, all of the numbers and all it digits intact are powers of 2, so this hypothesis, all of t Hem are powers of 2 is obvious. To reinforce her belief, she selects a list of numbers in which it is apparent this number of legible digits is strict Ly smaller than the number of lost ones, and asks you to find the smallest power of-2 (if any) whose a-digits With those of the list.

Thus must write a program such this given an integer, it determines (if it exists) the smallest exponentE suc h that the ' the ' 2E coincide with the digits (remember, more than half of the digits are).

Input

It is a set of the lines with a positive the integer N not bigger than 2147483648 in each of them.

Output

For every one of those integers a line containing the smallest positive integer E such that the the ' a ' of 2 E are precisely the digits of N, or, if there is no one, the sentence 'No. 2'.

Sample Input

1
2
10

Sample Output

7
8
20

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.