Root
InterviewTime limit1sMemory limit128 MB
For each pair B and N, find the positive integer A that makes A^N as close to B as possible.
- Level
Medium4 of 10
- Topics
- Binary search, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
Given positive integers and , write a program that finds the positive integer whose is closest to . In other words, output the that minimizes . Note that may be less than, equal to, or greater than .
Input
The input consists of several test cases. Each test case is a single line containing two integers and separated by a space. (, )
The last line of the input contains two zeros; this line is not processed.
Output
For each test case, output the corresponding on its own line.