BSEXP - Base Exploration
Problem Statement is easy, for a given number N, you have to print the base B such that if we write N in base B then it would contain most 0's at the end.
If more then one such base exist, which satisfy the given condition then print the smallest such base.
Input
The first line of the input consist of a single integer number t which determines the number of tests.
In each of next t lines there is a single integer number N.
Constraints
- 0 < t ≤ 105
- 2 ≤ N ≤ 1012
Output
Output contains one line with one integer B such that N written in base B has the most zeros at the end and is the smallest B with this property.
Example
Input: 2 72 18 Output: 2 3
Explanation
The answer for N=72 is B=2, because 72=10010002 (72 written in base 2) has 3 zeros at the end.
Using base 3, we only get 2 zeroes at the end (because 72=22003),
using base 6 would also give us 2 zeros, and no other base would give us more than 1 zero
For 18, 18=100102 and 18=2003 so answer will be 3.
Note: Test case were regenerated on 23 June 2020.
As rejudge is disabled by SPOJ please submit your code again.
hide comments
chhavisinha_12:
2021-07-10 15:48:18
only 15 testcases passed,rest gives tle |
|
anonymous:
2021-03-24 18:51:44
The problem statement should make clear that unary numeral system, i.e., base 1, is not a valid answer. |
|
Rafail Loizou:
2020-08-29 17:25:32
[NG]: Testdata are correct now and 39 AC's prove it. Please don't spell out algorithm details in comments.
|
|
athe1stb:
2020-08-16 20:46:48
bad tc. btw passed
|
|
julkas:
2020-06-25 13:12:12
@devilwolverine Not very fast :-). |
|
Vipul Srivastava:
2020-06-25 12:38:04
does this require [spoiler] algorithms?
|
|
nadstratosfer:
2020-06-23 03:12:27
[Angry rant removed]
|
|
Scape:
2020-06-22 22:48:17
@offamitkumar you should not delete comments. It's not nice. I see that you did the same thing in your previous problem (IFACTO) and other users complained about it as well. And if you've regenerated the test data you should rejudge all submissions too.
|
Added by: | Amit |
Date: | 2020-06-22 |
Time limit: | 1.5s-4.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |