HDU-6740-J. MUV LUV EXTRA

该博客讲述了如何解决一道关于寻找最可信循环节的数学问题。题目要求根据给定的参数和部分小数,确定最可信的循环节,可信度通过特定公式计算。博主提供了利用KMP算法求解循环周期的思路。
摘要由CSDN通过智能技术生成

HDU-6740-J. MUV LUV EXTRA

题目

MUV LUV EXTRA
Time Limit: 2000/1500 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 520 Accepted Submission(s): 159

Problem Description
One day, Kagami Sumika is stuck in a math problem aiming at calculating the length of a line segment with given statements and constraints. Since Sumika has no idea about it, she takes out a ruler and starts to measure the length. Unfortunately, the answer is an infinite decimal and she only got the first some digits of the answer from the ruler.
Sumika guesses that the answer is a rational number, which means that there exists two integers p, q that the answer equals qp. In this situation, the answer can be expressed as an infinte repeated decimal. For example, 12 = 0.500 … , 13 = 0.333 … , 910= 0.8999 … ,3635= 1.0285714285714 … .Sumika wants to guess the original number from the digits she got. Note that a number may has more than one way to be expressed such as 1.000 … = 0.999 … . Sumika won’t transform the digits she got to another form when guessing the original number.
Furthermore, Sumika relizes that for a repeating part, either too long or the appeared length too short will make the result unreliable. For example, if the decimal she measured is 1.0285714285714, it is obviously unreliable that the repeating part is “0285714285714”, since it is too long, or “428571”, since the appeared length is too short, which equals 7, the length of “4285714”. In this case, the best guess is “285714”, whose length is 6 and the appeared length is 12. So formally, she defines the reliability value of a repeating part, whose length is l and the appeared length is p, as the following formula:
a * p - b * l

Where a and b are given parameters.
Last but not least, you can ignore the integer parts of the decimal. It is just for restoring the scene. And the repeating part you guess should be completely repeated at least once and is still repeating at the end currently.
Please help Sumika determine the maximum reliability value among all repeating parts.

Input
The first

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值