-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhuaweiod1.cpp
111 lines (101 loc) · 1.96 KB
/
huaweiod1.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <cctype>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
double get_hulv_to_fen(const string& s)
{
if (s == "CNY") return 100;
if (s == "fen") return 1;
if (s == "JPY")
{
return static_cast<double>(10000) / 1825;
}
if (s == "sen")
{
return static_cast<double>(100) / 1825;
}
if (s == "HKD")
{
return static_cast<double>(10000) / 123;
}
if (s == "cents")
{
return static_cast<double>(100) / 123;
}
if (s == "EUR")
{
return static_cast<double>(10000) / 14;
}
if (s == "eurocents")
{
return static_cast<double>(100) / 14;
}
if (s == "GBP")
{
return static_cast<double>(10000) / 12;
}
if (s == "pence")
{
return static_cast<double>(100) / 12;
}
return 1;
}
double convert2fen(const string& s)
{
string a1, b1, a2, b2;
bool is_combind = false;
for (int i=0; i < s.size(); ++i)
{
if (i > 0 && isdigit(s[i]) && !isdigit(s[i-1]))
{
is_combind = true;
}
if (isdigit(s[i]) && !is_combind)
{
a1 += s[i];
}
if (isdigit(s[i]) && is_combind)
{
a2 += s[i];
}
if (!isdigit(s[i]) && !is_combind)
{
b1 += s[i];
}
if (!isdigit(s[i]) && is_combind)
{
b2 += s[i];
}
}
if (!is_combind)
{
return get_hulv_to_fen(b1) * stoi(a1);
}
else
{
return get_hulv_to_fen(b2) * (stoi(a1) * 100 + stoi(a2));
}
}
int main()
{
int N;
cin >> N;
vector<string> records;
records.reserve(N);
string s;
while (N--)
{
cin >> s;
records.emplace_back(s);
}
// io done
double sum = 0;
for (auto& r : records)
{
sum += convert2fen(r);
}
cout << static_cast<int>(sum) << endl;
return 0;
}