Files
python/TangDou/LuoGuBook/P1603.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

52 lines
2.0 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include<bits/stdc++.h>
using namespace std;
//原始英文数字
// You are a three eight pig . 10964
unordered_map<string, int> _map = {{"zero", 0},
{"one", 1},
{"two", 4},
{"three", 9},
{"four", 16},
{"five", 25},
{"six", 36},
{"seven", 49},
{"eight", 64},
{"nine", 81},
{"ten", 0},
{"eleven", 21},
{"twelve", 44},
{"thirteen", 69},
{"fourteen", 96},
{"fifteen", 25},
{"sixteen", 56},
{"seventeen", 89},
{"eighteen", 24},
{"nineteen", 61},
{"twenty", 0},
{"a", 1},
{"both", 4},
{"another", 1},
{"first", 1},
{"second", 4},
{"third", 9}
};
string s;
const int N = 1010;
int a[N];
int idx;
int main() {
//ctrl+d,或者ctrl+z结束
while (cin >> s)
if (_map[s]) a[idx++] = _map[s];
sort(a, a + idx);
string res = "";
for (int i = 0; i < idx; i++) {
if (i > 0 && a[i] < 10) res += "0" + to_string(a[i]);
else res += to_string(a[i]);
}
//第3个点需要特判没任何数字输出0很坑……
if (res != "") cout << res << endl;
else cout << 0 << endl;
return 0;
}