1.
算法学的一把渣,想了半天,还想到树啊左孩子右孩子什么的,完全忘记了排列组合这个神器。
2.
从上往下是暴力解法,从下往上就是有限的并且逐步减小的过程。
3.
数学不好是硬伤。下面是我在别人的博客上看到的解释:
There are 3 kinds of rational numbers:
Expansion is finite (for instance 1/4 = 0.25): those are numbers of the form (2^a)*(5^b).
Expansion is repetitive, from the start (like 1/7 = 0.(142857)). This is for numbers co-prime to 10.
Expansion is repetitive, after some initial non-repetitive section. This is for numbers that have both factors co-prime to 10 and are divisible by 2 or 5. (for example 1/14 = 0.0(714285)).
To find the longest cycle it’s sufficient to look just at the primes - because other numbers will just have the same cycles after some initial non-repetitive section.
然后模拟求循环节的过程就可以了。