http://acm.hdu.edu.cn/showproblem.php?pid=1202
刚开始没看到输入实数。。。汗、、、
View Code
#include <stdio.h> int main() { double s[100],p[100]; int n,i; double ss,sp; int cnt; while(~scanf("%d",&n)) { cnt=ss=sp=0; for(i=0;i<n;i++) { scanf("%lf%lf",s+i,p+i); if(p[i]==-1){cnt++;continue;} ss+=s[i]; if(p[i]>=90)sp+=4*s[i]; else if(p[i]>=80)sp+=3*s[i]; else if(p[i]>=70)sp+=2*s[i]; else if(p[i]>=60)sp+=s[i]; } if(cnt==n||sp==0)printf("-1\n"); else printf("%.2lf\n",sp/ss); } return 0; }