**Mr Farley series**

**definitions and theorems**

Definition one: The simplest fraction (also known as either a fraction or an irreducible fraction). If P,q's greatest common divisor is 1, we call the score p/q the simplest fraction.

Definition two: True score, if P,q is a positive integer, 0<p/q<1, we say p/q is the true fraction

Theorem:

Score A/b, C/D is the simplest true score (also 0/1 or 1/1) and A/b <c/d, there are

1) Number (A+C)/(B+D) is a minimal fraction

2) A/b < (A+C)/(B+d) < C/D

Proof slightly

**Definition of Mr Farley series:**

**The method of derivation of the method of thunder sequence:**

In the application theorem (2), if A/b and C/D are a sequence of Valeo, then p/q = (a+c)/(B+D) can be inserted between them (provided that the Q value is less than or equal to the given n value) so it can be constructed in two minutes, until not for example

N = 5:

**Step1: Prepare two numbers 0/1, 1/1 as the first and last element of the entire Valeo sequence 0/1, 1/1**

**Step2: Insert 1 numbers in the middle of two numbers 1/2, into 0/1, 1/1 **

**Step3: Insert 1 numbers in the middle of each pair of adjacent pairs, becoming 0/1, 1/3, 2/3, 1/1 **

** step4: Insert 1 numbers in the middle of each pair of adjacent pairs, becoming 1/4,1/3, , 1/2, 2/3, 3/4 1/1 **

**Between STEP5:0/1 and 1/4 and 3/4 and 1/1 can still be inserted 1 numbers, and the number of inserted denominator is not greater than 5 0/1, 1/5 , Quarter , 1/3, 2/5, , 3/5, 2/3, 3/4,< /c7> 4/5 , 1/1 **

At this point, the sequence contains all of the least-true fractions with a denominator of not more than 5, and the individual fractions are arranged in ascending order.

1#include <iostream>2#include <cstdio>3#include <cstring>4 #defineMAXN 80000005 using namespacestd;6 intn,t;7 intct=2;8 intTX[MAXN],TY[MAXN];9 voidFarey (intAintBintCintd)Ten { One if(B+d > N)return ; A /*if (b+d = = N) - { - printf ("%d/%d", a+c,b+d); the if (a+c! = N-1) printf (","); - return; - }*/ -Farey (a,b,a+c,b+d); + //printf ("%d/%d,", a+c,b+d); -tx[ct]=a+C; +ty[ct++]=b+D; AFarey (a+c,b+d,c,d); at } - intMain () - { -scanf"%d%d",&n,&t); -tx[1]=0; -ty[1]=1; inFarey (0,1,1,1); -tx[ct]=1; toty[ct]=1; + for(intI=1; i<=t;i++) - { the intm; *scanf"%d",&m); $ if(m>CT)Panax Notoginsengprintf"No solution\n"); - Else theprintf"%d/%d\n", Tx[m],ty[m]); + } A return 0; the}

The simplest fractional Farey sequence of number theory and the +poj3374 of the simple fraction