博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 3117 World Cup(我的水题之路——世界杯平局数目)
阅读量:4069 次
发布时间:2019-05-25

本文共 1959 字,大约阅读时间需要 6 分钟。

World Cup
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7208   Accepted: 3608

Description

A World Cup of association football is being held with teams from around the world. The standing is based on the number of points won by the teams, and the distribution of points is done the usual way. That is, when a teams wins a match, it receives 3 points; if the match ends in a draw, both teams receive 1 point; and the loser doesn’t receive any points.

Given the current standing of the teams and the number of teams participating in the World Cup, your task is to determine how many matches ended in a draw till the moment.

Input

The input contains several test cases. The first line of a test case contains two integers T and N, indicating respectively the number of participating teams (0 ≤ T ≤ 200) and the number of played matches (0 ≤ N ≤ 10000). Each one of the T lines below contains the name of the team (a string of at most 10 letter and digits), followed by a whitespace, then the number of points that the team obtained till the moment. The end of input is indicated by T = 0.

Output

For each one of the test cases, your program should print a single line containing an integer, representing the quantity of matches that ended in a draw till the moment.

Sample Input

3 3Brasil 3Australia 3Croacia 33 3Brasil 5Japao 1Australia 10 0

Sample Output

02

Source

, Brazil Subregion
有T个球队,N场比赛,如果赢了就得到3分,输了没有分,如果平局,两个队伍各1分,给出了T个球队所有队伍的最终得分,问,今年世界杯有多少个平局。
如果所有的队伍作为一个整体,有胜负的比赛,总分+3分,如果是平局,总分+2分,所以,平局数量是:如果所有比赛均有胜负的总分减去当前总分的分值。即:3 * N - SUM。
注意点:
1)样例有迷惑性,不是T*N-SUM(1WA)。
代码(1AC  1WA):
#include 
#include
int main(void){ int T, N; int i; char name[20]; int num,sum; while (scanf("%d%d", &T, &N), T != 0 || N != 0){ getchar(); for (i = sum = 0; i < T; i++){ scanf("%s%d", name, &num); getchar(); sum += num; } printf("%d\n", 3 * N - sum); } return 0;}

转载地址:http://vloji.baihongyu.com/

你可能感兴趣的文章
iOS获取手机的Mac地址
查看>>
ios7.1发布企业证书测试包的问题
查看>>
如何自定义iOS中的控件
查看>>
iOS 开发百问
查看>>
Mac环境下svn的使用
查看>>
github简单使用教程
查看>>
如何高效利用GitHub
查看>>
环境分支-git版本管理
查看>>
uni-app 全局变量
查看>>
js判断空对象的几种方法
查看>>
java 不用递归写tree
查看>>
springboot2 集成Hibernate JPA 用 声明式事物
查看>>
fhs-framework jetcache 缓存维护之自动清除缓存
查看>>
SpringBoot 动态编译 JAVA class 解决 jar in jar 的依赖问题
查看>>
fhs-framework springboot mybatis 解决表关联查询问题的关键方案-翻译服务
查看>>
ZUUL2 使用场景
查看>>
Spring AOP + Redis + 注解实现redis 分布式锁
查看>>
elastic-job 和springboot 集成干货
查看>>
php开发微服务注册到eureka中(使用sidecar)
查看>>
mybatis mybatis plus mybatis jpa hibernate spring data jpa比较
查看>>