Farmers League CodeChef Solution | CodeChef Problem Solution 2022
A football league of teams is taking place, where each team plays other teams once in single round robin fashion. A team gets points for winning a game and 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?
Input Format
- The first line of input will contain a single integer , 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 .
Output Format
For each test case, output in a single line the maximum difference of points between first and second place.
Constraints
Sample Input 1
4
2
3
4
9
Sample Output 1
3
3
6
12
Explanation
Test case : There will only be one match played between the two teams, therefore one team wins by points.
Test case : 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 points since one of team B and team C will win the game between them.
Test case : 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 points and second place has points, making a difference of .
Test case : It can be shown that it's not possible to achieve a difference higher than when teams play. One way of achieving this is for the winner to score points and second place to score .
Join Now for Solution:-
No comments:
Post a Comment