[Solution] Farmers League solution codechef

Farmers League solution codechef – A football league of NN teams is taking place, where each team plays other teams once in single round robin fashion. A team gets 33 points for winning a game and 00 for losing (assume that no games end in a draw/tie). What is the maximum possible difference of points between the winning team and the second-placed team?

[Solution] Farmers League solution codechef

  • The first line of input will contain a single integer TT, denoting the number of test cases. Then the test cases follow.
  • Each test case consists of a single line of input, containing a single integer NN.

Output Format

For each test case, output in a single line the maximum difference of points between first and second place.

Constraints

  • 1T1051≤T≤105
  • 2N1092≤N≤109

[Solution] Farmers League solution codechef

 

4
2
3
4
9

Sample Output 1 

3
3
6
12

Farmers League solution Explanation

Test case 11: There will only be one match played between the two teams, therefore one team wins by 33 points.

Test case 22: Let the three teams be A, B, C. If team A wins both the games against team B and team C, then team A will win by 33 points since one of team B and team C will win the game between them.

Test case 33: Let the four teams be A, B, C, D. One possibility is for A to win all its games, and then B beats C, C beats D, D beats B. This way, the winner has 99 points and second place has 33 points, making a difference of 66.

Test case 44: It can be shown that it’s not possible to achieve a difference higher than 1212 when 99 teams play. One way of achieving this is for the winner to score 2424 points and second place to score 1212.

For Solution

Click here

Leave a Comment