3 条题解
-
0
没那么多追求,能过就行
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] lastT = new int[3]; double v = 0; double s = 0; String str = sc.nextLine(); char[] chs = str.toCharArray(); for (int i = 0,n = 0; i < chs.length; i++){ if(i < 8){ if(chs[i] == ':'){ n++; continue; } lastT[n] = chs[i]-'0'+lastT[n]*10; }else { if(chs[i] >='0' && chs[i] <= '9'){ v = v*10 + chs[i]-'0'; } } } while(sc.hasNext()){ str = sc.nextLine(); chs = str.toCharArray(); double nv = 0; boolean flag = true; int[] time = new int[3]; for (int i = 0,n = 0; i < chs.length; i++){ if(i < 8){ if(chs[i] == ':'){ n++; continue; } time[n] = chs[i]-'0'+time[n]*10; }else { if(flag){ flag = false; } if(chs[i] >='0' && chs[i] <= '9'){ nv = nv*10 + chs[i]-'0'; } } } double dt = (time[0]-lastT[0])+ (double) (time[1] - lastT[1]) /60+(double) (time[2] - lastT[2]) /3600; s = s + v * dt; if(!flag){ v = nv; }else System.out.printf(str+" %.2f km\n",s); lastT[0] = time[0]; lastT[1] = time[1]; lastT[2] = time[2]; } } }
信息
- ID
- 4
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- 9
- 标签
- (无)
- 递交数
- 35
- 已通过
- 4
- 上传者