Connection Status:
Competition Arena > ThreeFractions
SRM 838 · 2022-09-19 · by misof · Simple Math
Class Name: ThreeFractions
Return Type: int[]
Method Name: find
Arg Types: (int, int, int, int)
Problem Statement

Problem Statement

We have two fractions: a smaller fraction N1 / D1 and a bigger fraction N2 / D2.

Your task is to find three more fractions: A/B, C/D, and E/F.

These three fractions must have three distinct values, and they must all lie strictly between N1 / D1 and N2 / D2.

All values A, B, C, D, E, F must be integers between 1 and 10^9, inclusive.

Return the int[] {A, B, C, D, E, F}. All valid solutions will be accepted.

Constraints

  • Each number in the input will be between 1 and 5000, inclusive.
  • The value of N1 / D1 will be strictly smaller than the value of N2 / D2.
Examples
0)
1
3
2
3
Returns: {1, 2, 3, 5, 147, 233 }

We are looking for three fractions between 1/3 and 2/3. The three returned fractions are 1/2 = 0.5, 3/5 = 0.6, and 147/233 = approximately 0.631.

1)
1
7
7
1
Returns: {2, 1, 5, 1, 3, 1 }

We are looking for three fractions between 1/7 and 7/1. The three returned fractions are 2/1, 5/1, and 3/1.

2)
2
3
3
4
Returns: {7, 10, 71, 100, 47, 69 }
3)
2584
4181
1597
2584
Returns: {26708225, 43214816, 26708226, 43214816, 26708227, 43214816 }
4)
7
9
4
1
Returns: {29, 36, 30, 36, 31, 36 }

Submissions are judged against all 110 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class ThreeFractions with a public method vector<int> find(int N1, int D1, int N2, int D2) · 110 test cases · 2 s / 256 MB per case

Submitting as anonymous