mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-30 18:56:26 +00:00
P2108 学英语
R52635743
This commit is contained in:
parent
25ce10f451
commit
caf0293b04
@ -3,10 +3,9 @@
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
map<string, int> m;
|
||||
string s;
|
||||
long long ans = 0, now = 0;
|
||||
|
||||
map<string, int> m;
|
||||
int ans = 0, tmp = 0, w = 1;
|
||||
m["one"] = 1;
|
||||
m["two"] = 2;
|
||||
m["three"] = 3;
|
||||
@ -34,33 +33,22 @@ int main() {
|
||||
m["seventy"] = 70;
|
||||
m["eighty"] = 80;
|
||||
m["ninety"] = 90;
|
||||
|
||||
while (cin >> s) {
|
||||
if (s == "negative") {
|
||||
cout << "-";
|
||||
}
|
||||
else if (s == "hundred") {
|
||||
ans += now;
|
||||
ans *= 100;
|
||||
now = 0;
|
||||
}
|
||||
else if (s == "thousand") {
|
||||
ans += now;
|
||||
ans *= 1000;
|
||||
now = 0;
|
||||
}
|
||||
else if (s == "million") {
|
||||
ans += now;
|
||||
ans *= 1000000;
|
||||
now = 0;
|
||||
}
|
||||
else {
|
||||
now += m[s];
|
||||
w = -1;
|
||||
} else if (s == "hundred") {
|
||||
tmp *= 100;
|
||||
} else if (s == "thousand") {
|
||||
ans += tmp * 1000;
|
||||
tmp = 0;
|
||||
} else if (s == "million") {
|
||||
ans += tmp * 1000000;
|
||||
tmp = 0;
|
||||
} else {
|
||||
tmp += m[s];
|
||||
}
|
||||
}
|
||||
if (now) {
|
||||
ans += now;
|
||||
}
|
||||
cout << ans << endl;
|
||||
ans += tmp;
|
||||
cout << w * ans << endl;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user