hdoj-1036-Average is not Fast Enough!(水題,坑)
阿新 • • 發佈:2018-05-04
ID print pan tdi size tin () ++ std
題目鏈接:Average is not Fast Enough!
1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <cstdio> 5 using namespace std; 6 int main() 7 { 8 int n, id; 9 double d; 10 cin>>n>>d; 11 while (cin>>id) {12 printf("%3d: ", id); 13 int mark = 0; 14 int time = 0; 15 for (int i=0; i<n; i++) { 16 string str; 17 cin>>str; 18 if (str[0] == ‘-‘) { 19 mark = 1; 20 // printf("-\n");不能在這裏輸出,因為會碰到多個不及格的,WA了數次21 } 22 if(mark==1)continue; 23 time += (str[0]-‘0‘) * 3600+ ((str[2]-‘0‘)*10+(str[3]-‘0‘)) * 60 + (str[5]-‘0‘)*10+(str[6]-‘0‘); 24 } 25 if (mark == 1) { 26 printf("-\n"); 27 continue; 28 } 29 double a = time / d;30 int t = (int)(a + 0.5); 31 printf("%d:%02d min/km\n", t/60, t%60); 32 } 33 return 0; 34 }
hdoj-1036-Average is not Fast Enough!(水題,坑)