1617 Finding Bovine Roots 解题报告

本文探讨了一种特殊的平方根计算方法,即“Bovine平方根”。此方法旨在找到最小整数,其Bovine平方根的小数部分以特定数字串开始。文章通过示例解释了这一概念,并提供了一段C语言代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Finding Bovine Roots

时间限制(普通/Java):1000MS/10000MS     运行内存限制:65536KByte
总提交: 4            测试通过: 3

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1617

描述

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

 

说来惭愧 这个题目是看着别人代码理解的,从topsky那里的代码理解的,感谢他首先,一位热心且实力派的ACM爱好者。

废话不多了,看看代码你们就懂了也就。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

helihui123

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值