Submit | All submissions | Best solutions | Back to list |
FACVSPOW - Factorial vs Power |
Consider two integer sequences f(n) = n! and g(n) = an, where n is a positive integer. For any integer a > 1 the second sequence is greater than the first for a finite number of values. But starting from some integer k, f(n) is greater than g(n) for all n >= k. You are to find the least positive value of n for which f(n) > g(n), for a given positive integer a > 1.
Input
The first line of the input contains number t – the amount of tests. Then t test descriptions follow. Each test consist of a single number a.
Constraints
1 ≤ t ≤ 100000
2 ≤ a ≤ 106
Output
For each test print the least positive value of n for which f(n) > g(n).
Example
Input: 3 2 3 4 Output: 4 7 9
Added by: | Spooky |
Date: | 2009-11-01 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | Advancement Autumn 2009, http://sevolymp.uuuq.com/ |
hide comments
|
||||||
2009-11-26 16:21:56 Spooky
Maybe we can't. Although those are not billion digit numbers. Several slightly different approaches give the same results. And also I've checked some test cases with rather big numbers using Maple. |
||||||
2009-11-26 15:11:21 amaroq
How can we be sure that we have enough precision if we can't work with billion digit numbers? |