[恢]hdu 2061

2011-12-16 05:53:55

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2061

题意:算n个成绩的GPA(不是平均学分绩点,是平均学分成绩)。

mark:坑爹,s<60写成了s<=60。另外把%lf改成%d居然会TLE。

代码:

# include <stdio.h>

char name[35] ;


int main ()
{
int T, n, flag, nCase = 1 ;
double c, s ;
double tc, ts ;
scanf ("%d%*c", &T) ;
while (T--)
{
scanf ("%d%*c", &n) ;
tc = ts = 0 ;
flag = 0 ;
while (n--)
{
scanf ("%s %lf %lf%*c", name, &c, &s) ;
tc += c ;
ts += s*c ;
if (s>=0 &&s<60) flag = 1 ;
}
if (nCase++ != 1) printf ("\n") ;
if (flag || tc == 0) puts ("Sorry!") ;
else printf ("%.2lf\n", ts/tc) ;
}
return 0 ;
}



原文地址:https://www.cnblogs.com/lzsz1212/p/2314945.html