Question Link
Question: There are n teams playing each game. Each of the two teams plays two games (one for home and away). The game wins three points, and the score is equal to one point. After the competition, a dream team will be selected to meet the following conditions: the total number of goals is the maximum (not the same as that of the team), the maximum number of victories (not the same as that of the team), and the minimum number of missed goals (not the same as that of the team ). Find the lowest possible ranking of the dream team. The ranking of a team with a score of P is equal to the number of teams with an equal score strictly greater than P plus 1.
Train of Thought: in fact, the three conditions are the most useful only for the number of victories, because the Dream Team can win the game with a big score, the loss of the game is 0-1 to lose the opponent, the other two do not matter. To keep the Dream Team as low as possible, it means to keep the score as low as possible. We assume that the number of victories for the mengzhi team is 2, and the number of victories for other teams is 1. This satisfies the above conditions and minimizes the score of the mengzhi team.
When the number of participating teams is N:
Dream Team: Win 2 games, negative n-1, flat n-3 = 2*3 + n-3 = 3 + n
Among them 2 teams: Win 1 game, play 1 game, Flat 2 * n-4 = 1*3 + 2 * n-4 = 2 * n-1
Remaining Team (when n> 3 remaining team): Win 1 game, 0 game, 2 * n-3 = 2 * n
Therefore, the ranking can be obtained based on the score.
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main() { int n; while (scanf("%d", &n) && n) { if (n <= 3) printf("1\n"); else if (n == 4) printf("2\n"); else printf("%d\n", n); } return 0;}