Finding Bovine Roots
总提交: 4 测试通过: 3
http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1617
描述
The erroneous ciphering does, however, lead to an interesting question. Given a string of digits of length L (1 <= L <= 9), what is the smallest integer whose bovine square root decimal part begins with those digits?
By way of example, consider the string "123". The square root of 17 is approximately 4.1231056256176605498214098559740770251472 so the bovine square root is: 0.1231056256176605498214098559740770251472 whose decimal part (just after the period) starts with 123. It turns out that 17 is the smallest integer with this property.
输入
Line 2: L digits (with no spaces)
输出
Line 1: A single integer that is the smallest integer whose bovine square root starts with the supplied string
样例输入
3
123
样例输出
17
提示
Be careful of floating point arithmetic. It engenders rounding errors that can be surprising.
Explanation of the sample:
sqrt(17) ~= 4.1231056256176605498214098559740770251472
说来惭愧 这个题目是看着别人代码理解的,从topsky那里的代码理解的,感谢他首先,一位热心且实力派的ACM爱好者。
废话不多了,看看代码你们就懂了也就。