21922_FindingBovineRoots

2022-5-16 18:20| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505962195900-Problem List-采集的数据-后羿采集器.html

Pro.ID

21922

Title

Finding Bovine Roots

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21922

AC

6

Submit

13

Ratio

46.15%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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)

    输出

    Description

    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.

    Input

    Line 1: A single integer, L

    Line 2: L digits (with no spaces)

    Output

    Line 1: A single integer that is the smallest integer whose bovine square root starts with the supplied string

    Sample Input

    3
    123

    Sample Output

    17

    Hint

    Be careful of floating point arithmetic. It engenders rounding errors that can be surprising.

    Explanation of the sample:

    sqrt(17) ~= 4.1231056256176605498214098559740770251472

    Source

    样例输入

    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


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部