当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3175:Finding Bovine Roots

题目描述
The cows are trying to find their roots. They are not so smart as humans when they find square roots, the cows lose the integer portion of their square root calculation. Thus, instead of calculating the square root of 2 to be 1.4142135623730950488016887242096980785696, they deduce that it is 0.4142135623730950488016887242096980785696. The square root of 16 is calculated to be 0 (obviously an error).

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 1: A single integer, L

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

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3175

最后修改于 2020-10-29T06:54:59+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536