poj 3117 World Cup

来源:互联网 发布:泰迪熊代挂软件官网 编辑:程序博客网 时间:2024/05/02 04:40
//仔细分析题意之后,就会觉得这是一道好简单的题:赢球得3分,输球得0分,平局得1分!现在假设有3场球赛://如果没有输球的球队,则总的分数为9分,如果有一场是平局的情况下,则总的分数为:平局的2分加上赢球的3*2,总共为8分;//如果有二场是平局的情况下,则总的分数为:平局的2*2加上赢球的3*1,总共为7分,按照这样的规律分析下去,结果就出来了! #include <iostream>#include <string>using namespace std;struct Info{     string name;     int scores;}team[250];int main(){    int i, t, n, sum, ans, tot;    while (cin >> t >> n)    {          if (t == 0)  break;          sum = 0;          for (i = 0; i < t; i++)          {              cin >> team[i].name >> team[i].scores;              sum += team[i].scores;          }          tot = n * 3;          ans = tot - sum;          cout << ans << endl;    }        system("pause");}

原创粉丝点击