http://acm.hdu.edu.cn/showproblem.php?pid=1036
原本是水题不解释……可是nc的wa了n次,orz了,输出的地方少了个冒号---------
题目说的就是接力赛的速度计算,如果是-:--:--就不算速度,如果是其他的就都化成秒加起来,如果再四舍五入得到答案
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include<stdio.h> #include<string.h> int main() { double d,sum,i; int team,n,flag=0,s; char time[10000]; scanf("%d%lf",&n,&d); while(scanf("%d",&team)!=EOF) { sum=0.0; flag=1; for(i=0;i<n;i++) { scanf("%s",time); if(strcmp(time,"-:--:--")==0) { flag=0; } else { if(time[1]==':') sum+=(time[0]-'0')*3600.0+(time[2]-'0')*600.0+(time[3]-'0')*60.0+(time[5]-'0')*10.0+(time[6]-'0')*1.0; else sum+=(time[0]-'0')*36000.0+(time[1]-'0')*3600.0+(time[3]-'0')*600.0+(time[4]-'0')*60.0+(time[6]-'0')*10.0+(time[7]-'0')*1.0; } } if(flag==0) { printf("%3d: -\n",team); continue; } s=(int)(sum/d+0.5); printf("%3d: %d:%02d min/km\n",team,s/60,s%60); } return 0; }