您的位置:首页 > 其它

UVALive - 4094 WonderTeam

2016-07-08 23:01 483 查看
A - WonderTeam

Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu

Submit

Status

Practice

UVALive 4094

Description

Download as PDF

The Brasileiro League is the most important event in Brazil. There are n football teams participating in the competitions, each team plays twice (home and away) against each other team. Each team receives three points for a win and one point for a draw. No point is awarded for a loss.

When the games are finished, teams are ranked by numbers from 1 to n according to the total points. The rank of each team t having p points is one plus the number of teams having more than p points. It is possible that more than one team have the same ranks.

In addition to the Champion (the first ranked team or teams), the WonderTeam is also awarded, if there exists one. The team that has absolutely the highest number of wins (absolutely means no other teams has the same number of wins), absolutely the highest number of goals scored, and absolutely the lowest number of goals conceded, is called the WonderTeam. (WonderTeam should have all these properties.)

Your task is to find out the worst possible rank for the WonderTeam.

Input

There are multiple test cases in the input. Each test case consists of only one line containing n(1≤n≤50) , the number of teams in league. The input terminates with a line containing ` 0’.

Output

For each test case, write a single line containing the worst possible rank for the WonderTeam.

Sample Input

1

3

0

Sample Output

1

1

题意:

一个足球联赛,每个队要和另外所有队踢两场;

胜利3分,平局1分,失利0分;最后出了要决出冠军,还要决出一个wonder team,就是胜场最多,进球最多,失球最少(都不能有并列)(胜场最多不一定排名高,因为它可能输了很多,平局很少,别人都是平局,积分就比它多),问wonder team排名最靠后是多少;

思路:

首先胜场多,排名靠后,那么只有一个原因,它平局很少,赢了几场,但剩下都是输的;

先拿5支球队推算;就ABCDE吧;

我们要让A成为wonder team;

A和BC踢是一胜一负;A和DE踢都是一平一负;然后剩下所有比赛都是平局;

那么出现什么情况;A 2胜4负2平(胜了AB) 8分

BC 1胜1负6平 9分

DE 1胜7平 10分;

A是wonder team排名垫底

所以大于5场也都可以这样算,它让它稳定的2胜然后别的球队1胜,但是平局比它多4场以上(大于等于5支球队就能做到)

但是小于5支就不行了;你看上面那种方案,如果只有4支,那么少平了2场,积分7,A积分也7,那就不一定垫底了;

那么我们可以知道,小于等于3支球队,赢得最多肯定是冠军了;平局最多相差也不超过3,也就是多赢一场,积分就追不回来了;

但如果刚好4支,按照上面那种打法,这种打法是保证胜场最多,负场也最多,平局最少的打法了,我们也会排到第2;

所以分三种情况输出就行了;

代码:

#include<cstdio>
#include<cstring>

int n;

int main() {
while(scanf("%d",&n) && n) {
if(n < 4)
printf("1\n");
else if(n == 4)
printf("2\n");
else
printf("%d\n",n);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  UVA