poj 3117(简单数学题) World Cup
来源:互联网 发布:企业淘宝费用是多少 编辑:程序博客网 时间:2024/04/28 20:19
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 integersT and N, indicating respectively the number of participating teams (0 ≤T ≤ 200) and the number of played matches (0 ≤ N ≤ 10000). Each one of theT 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 byT = 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
思路:
设平局为X场,不是平局的为Y场,已知总场数为N,sum为总分数
则有 X+Y=N;
2*X+3Y=sum;
解得:X=3*N-sum;
编程的时候一定要注意啊:N可以为0,习惯性的写成了while(scanf("%d%d",&T,&N)==2&&T&&N) 最后一直wa啊!!!
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <vector>#include <cmath>using namespace std;int main(){ //freopen("in.txt","r",stdin); int T,N; while(scanf("%d%d",&T,&N)==2) { if(T==0&&N==0) break; string str; int sum=0,goal; for(int i=1;i<=T;i++) { cin>>str>>goal; sum+=goal; } int ans=N*3-sum; printf("%d\n",ans); } return 0;}
- poj 3117(简单数学题) World Cup
- poj 3117 World Cup(简单数学题)
- POJ 3117 World Cup (简单数学题) --from lanshui_Yang
- POJ 3117 World Cup
- poj 3117 World Cup
- poj 3117 World Cup
- Poj 3117 World Cup
- POJ 3117 World Cup
- 【POJ】:POJ 3117 World Cup
- poj 3117 World Cup 规律
- poj 3117 水题 World Cup
- POJ 3117 World Cup G++
- POJ-World Cup Noise 简单DP
- POJ 3117 World Cup(水~)
- poj 1953 World Cup Noise
- POJ 1953 World Cup Noise
- poj 1953 World Cup Noise
- POJ 1953 World Cup Noise
- Introducing iOS Boilerplate A base template for iOS apps
- Myeclipse 连接SQL Server
- android弹出对话框大全
- SRILM 语言模型训练工具
- spring mvc 之注释版
- poj 3117(简单数学题) World Cup
- coursera NLP学习笔记之week1最小编辑距离计算
- ssh 有时候遇到的问题;
- 如何判断链表是否有环的存在
- Tomcat配置文件Host元素属性介绍
- C++拷贝构造函数详解
- 里程碑图、横道图、项目进度网络图比较
- Spring源代码解析(四):Spring MVC
- NFC技术简介