求一个acm题的算法

来源:百度知道 编辑:UC知道 时间:2024/05/22 15:21:57
Problem A: Is it possible?
Skywind does not excel at the sports, but he like sports news, for example, the news of Chinese soccer super league. It is all known that in soccer competition, if A win B, A win get 3 points and B get zero, both get 1 point if tie. When he is busy with the ACM contest these days, he missed the most recent news. Karen, one of his student, told him the lastest points of every club teams. Karen said: "Team A: 3 matches, 9 points; Team B: 3 matches, 3 points; Team C: 2 matches, 1 points;" (assume only three teams). "It is NOT possible", skywind told karen.

Can you find out the reason? The summary point of these teams is more than 3*4; Maybe other mistakes can be found also.

Can you judge whether the point list is possible or not?

Input
The first line of each case is a integer n (n <=20), the number of teams. The following n lines are team's info such as name, matches, points. The team name c

#include <iostream>
#include <string>

using namespace std;
#include <math.h>
#include <ctype.h>
int main()
{
int l,i,j,n,g[100],s[100],win,lose,tie,countg,counts,temp1,temp2,sign,blank,gg,ss,t;
char name[100][101],ch[110],cg[100],cs[100];
while(cin>>n)
{
for(j=0;j<100;j++)
{
g[j]=0;
s[j]=0;
}
sign=0;
win=0;
lose=0;
tie=0;
countg=0;
counts=0;
getchar();
for(i=0;i<n;i++)
{
gg=0;
ss=0;
blank=0;
temp1=0;
temp2=0;
gets(ch);
l=strlen(ch);
//cout<<l<<endl;
for(j=l-1;j>=0;j--)
{
if(ch[j]==' ') blank++;
if(blank>=2) break;
if(ch[j]!=' ' && blank==0)
{
cs[ss]=ch[j];
ss++;
}
if(ch[j]!=' ' && blank==1)
{
cg[gg]=c