We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #71: Ordered fractions
Project Euler #71: Ordered fractions
Sort by
recency
|
15 Discussions
|
Please Login in order to post a comment
If you are coding with Java, use BigIntegers
using System;
public class Program { public static (int, int, int) Egcd(int a, int b) { if (a == 0) return (b, 0, 1); else { var (g, y, x) = Egcd(b % a, a); return (g, x - (b / a) * y, y); } }
}
Here is my solution. Super fast in python 3
Find my java solution here
别看下面几位大爷的瞎BB。
(b*N-1)/(N*X) is a fraction less than b/a. Take the k step continued fraction of the fraction and calculate the denominator of the fraction represented by the continued fraction. Use Binary Search for k in range(1,32).