求不超过 1257/2009 的最大分数 p/q(q≤2009)。
由连分数展开 1257/2009=[0;1,1,1,2,22,2,5],或其 Farey 左邻居。
解 1257q−2009p=1,q≤2009。由扩展欧几里得算法得最小正整数解 (p,q)=(229,366)。
229/366 为 F2009 中 1257/2009 的直接前驱。已约分,gcd=1。
p0+q0=229+366=595。
英文解析
S={p/q:q≤2009,p/q<1257/2009,p,q∈N}. Find max element p0/q0 in reduced form, compute p0+q0.
This is finding the fraction just below 1257/2009 with denominator ≤2009. This is a Farey sequence / continued fraction problem.
Compute the continued fraction of 1257/2009 and take the penultimate convergent, or use the property of Farey neighbors.
2009/1257: 2009=1⋅1257+752. 1257=1⋅752+505. 752=1⋅505+247. 505=2⋅247+11. 247=22⋅11+5. 11=2⋅5+1. 5=5⋅1+0.
Continued fraction: 1257/2009=[0;1,1,1,2,22,2,5].
The convergents:
c0=0/1
c1=1/1
c2=1/2
c3=2/3
c4=5/8
c5=112/179 (since 2+1/22=45/22, then invert... let me compute properly)
c6=229/366
c7=1257/2009
Actually, let me compute the convergents step by step:
[0;1,1,1,2,22,2,5]
p−2=0,p−1=1,q−2=1,q−1=0
a0=0: p0=0,q0=1
a1=1: p1=1,q1=1
a2=1: p2=1,q2=1+1=2... wait: p2=a2p1+p0=1⋅1+0=1, q2=a2q1+q0=1⋅1+1=2.
a3=1: p3=1⋅1+1=2, q3=1⋅2+1=3.
a4=2: p4=2⋅2+1=5, q4=2⋅3+2=8.
a5=22: p5=22⋅5+2=112, q5=22⋅8+3=179.
a6=2: p6=2⋅112+5=229, q6=2⋅179+8=366.
a7=5: p7=5⋅229+112=1257, q7=5⋅366+179=2009.
The convergents are: 0/1, 1/1, 1/2, 2/3, 5/8, 112/179, 229/366, 1257/2009.
The fraction just below 1257/2009 with denominator ≤2009: among fractions with denominator ≤2009, the maximum less than 1257/2009 could be a Farey neighbor or a convergent. The penultimate convergent 229/366 is less than 1257/2009.
Check other candidates: the fraction (1257k−1)/(2009k) for appropriate k, or use the mediant of convergents.
For the best rational approximation with bounded denominator, we check fractions between 229/366 and 1257/2009. The mediant is (229+1257)/(366+2009)=1486/2375, denominator > 2009.
We can also compute (1257m−1)/(2009m) for m=1: 1256/2009, which is less than 1257/2009 and has denominator 2009. But is there a fraction with denominator ≤ 2009 that's between 1256/2009 and 1257/2009?
Actually, using the theory: the fraction just below a/b in the Farey sequence of order N is obtained from the extended Euclidean algorithm. For 1257/2009 with N=2009, the previous term in F2009 is found by solving 2009x−1257y=1 for positive x,y with x≤2009. Then (x−y)/x or similar...
Solving 2009x−1257y=1:
2009−1⋅1257=752
1257−1⋅752=505
752−1⋅505=247
505−2⋅247=11
247−22⋅11=5
11−2⋅5=1
Working backwards:
1=11−2⋅5
=11−2(247−22⋅11)=45⋅11−2⋅247
=45(505−2⋅247)−2⋅247=45⋅505−92⋅247
=45⋅505−92(752−505)=137⋅505−92⋅752
=137(1257−752)−92⋅752=137⋅1257−229⋅752
=137⋅1257−229(2009−1257)=366⋅1257−229⋅2009
So x=366, y=229. Check: 2009⋅366−1257⋅229=735294−287853=447441? That's not 1. Let me recheck.
Hmm, that doesn't give 1. Let me redo: 366⋅1257−229⋅2009=1.
366⋅1257=366⋅1257. 366⋅1200=439200,366⋅57=20862. Sum = 460062.
229⋅2009=229⋅2000+229⋅9=458000+2061=460061.
Yes: 460062 - 460061 = 1. ✓
So (x,y)=(366,229) with 2009⋅366−1257⋅229=−1, wait:
Actually 2009⋅(−366)+1257⋅229=−1, so 1257⋅229−2009⋅366=−1, so 2009⋅366−1257⋅229=1. So x=366,y=229.
The fraction just below 1257/2009 in F2009 is (1257⋅229−1)/(2009⋅229) ... hmm, that's not right.
The standard result: if bx−ay=1, then y/x<a/b and y/x is the immediate predecessor of a/b in the Farey sequence Fb.
Here 2009⋅366−1257⋅229=1, wait no: 2009⋅366−1257⋅229=735294−287853=447441, not 1.
I had the signs wrong. Let me redo: 1257⋅229−2009⋅366=−1, so 2009⋅366−1257⋅229=1. But 366 and 229 are the coefficients, not the numerator/denominator.
Actually, the equation a⋅x−b⋅y=±1 gives Farey neighbors. If 2009x−1257y=1, then y/x is the predecessor. Here 2009⋅366−1257⋅229=1 doesn't hold. Let me check: 2009⋅366=735294. 1257⋅229=287853. 735294−287853=447441=1.
I made an arithmetic error. Let me redo the extended Euclidean algorithm properly.
Actually, from the earlier backward substitution:
366⋅1257−229⋅2009=460062−460061=1. ✓
So 1257⋅366−2009⋅229=1. Rearranged: 2009⋅229−1257⋅366=−1. The Farey neighbor below 1257/2009 with denominator ≤ 2009 is 229/366.
But wait, 229/366<1257/2009? 229⋅2009=460061, 1257⋅366=460062. Yes, 229⋅2009<1257⋅366, so 229/366<1257/2009.
Is there any fraction between 229/366 and 1257/2009 with denominator ≤ 2009? The next fraction in F2009 after 229/366 is the mediant with the next Farey neighbor.
The mediant (229+1257)/(366+2009)=1486/2375 has denominator > 2009. The fraction just below 1257/2009 in F2009 is NOT necessarily 229/366 because there could be fractions between them with denominator ≤ 2009.
Let me check: we need the largest fraction p/q<1257/2009 with q≤2009. This is equivalent to finding the fraction p/q maximizing p/q subject to 2009p−1257q<0 and q≤2009.
2009p−1257q≤−1. Minimize 1257q−2009p subject to this being positive and q≤2009.
The optimal solution to 1257q−2009p=1 with q≤2009 gives the answer. From above: 1257⋅366−2009⋅229=1, so q=366, p=229. But 366≤2009, so this is feasible. The fraction is 229/366.
But we can also try 1257q−2009p=k for k>1, which would give a fraction even closer to 1257/2009 (since (1257q−k)/(2009q)<1257/2009, and as k increases, the fraction gets smaller, not larger). Wait: for p/q<1257/2009, we want the LARGEST such fraction. 1257/2009−p/q=(1257q−2009p)/(2009q). To maximize p/q, we minimize 1257q−2009p (positive). The minimum positive value is 1.
So the maximum fraction p/q<1257/2009 with denominator unbounded but q≤2009 is given by solving 1257q−2009p=1 with q≤2009. The solution with smallest q is (p,q)=(229,366). But wait, we want to MAXIMIZE p/q, not minimize q. With 1257q−2009p=1, p=(1257q−1)/2009. For this to be integer, 1257q≡1(mod2009). The smallest positive q is 366, giving p=229. The next q would be 366+2009=2375, which exceeds 2009.
So p0=229, q0=366. The fraction is 229/366 in reduced form (gcd=1). p0+q0=229+366=595.
But wait, is 229/366 really the max? Let me verify: 229/366≈0.62568, 1257/2009≈0.62568... 1257/2009=0.625684... 229/366=0.625683... Yes, very close.
Could there be a fraction p/q with q<366 that's even closer? Let me check: 1257/2009−5/8=0.62568−0.625=0.00068. 1257/2009−229/366≈0. 5/8=0.625. Compare: 5⋅2009=10045, 1257⋅8=10056. 10045<10056, so 5/8<1257/2009.
The gap: 1257/2009−5/8=(1257⋅8−2009⋅5)/(2009⋅8)=(10056−10045)/16072=11/16072≈0.000684.
The gap: 1257/2009−229/366=1/(2009⋅366)≈1/735294≈0.00000136.
So 229/366 is much closer. Is there any fraction between with denominator ≤ 2009? The Farey sequence property guarantees that between Farey neighbors there's no fraction with smaller denominator. Since 229/366 and 1257/2009 are neighbors in some Farey sequence (specifically Fmax(366,2009)=F2009), there's no fraction between them with denominator ≤ 2009.
So the max is 229/366, p0+q0=595.
But let me double-check: 229 and 366 are coprime? gcd(229,366): 366 = 1·229+137, 229=1·137+92, 137=1·92+45, 92=2·45+2, 45=22·2+1. Yes, gcd=1.
Reduced form: 229/366. p0+q0=595.