-
Notifications
You must be signed in to change notification settings - Fork 14
/
10281.cpp
60 lines (57 loc) · 1.24 KB
/
10281.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define FOI(i, A, B) for(i=A; i<=B; i++)
#define FOD(i, A, B) for(i=A; i>=B; i--)
double toDouble(string s){
stringstream ss(s);
double D;
ss >> D;
return D;
}
int main(){
//freopen("testI.txt", "r", stdin);
//freopen("testO.txt", "w", stdout);
double last = 0.0;
double dis = 0.0, speed = 0.0;
string temp;
while( getline(cin, temp) ){
stringstream ss(temp);
string str = "", s = "";
ss >> str >> s;
double curr = ( (str[0] - '0') * 10 + (str[1] - '0') ) / 1.0;
curr += ( (str[3] - '0') * 10 + (str[4] - '0') ) / 60.0;
curr += ( (str[6] - '0') * 10 + (str[7] - '0') ) / 3600.0;
dis += ( speed * (curr - last) );
last = curr;
//cout << temp << endl;
if( s == "" )
printf("%s %2.2lf km\n", str.c_str(), dis);
else
speed = toDouble(s);
}
return 0;
}