forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabylonian.cpp
46 lines (40 loc) · 954 Bytes
/
babylonian.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
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
int main() {
ll cases;
cin >> cases;
while(cases--) {
vector<ll> v;
string s;
cin >> s;
string actual;
for(auto c : s) {
if(c == ',') {
actual.push_back(',');
actual.push_back('0');
}
else {
actual.push_back(c);
}
}
vector<string> split;
split.push_back("");
for(auto c : actual) {
if(c == ',') {
split.push_back("");
}
else {
split[split.size()-1].push_back(c);
}
}
ll total = 0;
for(ll i = 0; i < split.size(); i++) {
string temp = split[split.size()-i-1];
total += pow(60, i) * stoi(temp);
}
cout << total << endl;
}
}