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
| #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int, int> pii;
#define rep(i, a, n) for (int i = a; i < n; ++i) #define per(i, a, n) for (int i = n - 1; i >= a; --i) #define pb push_back #define mp make_pair #define INF 0x3f3f3f3f #define EPS 1e-8 #define all(x) x.begin(), x.end()
const int maxn = 1e3 + 5;
map<string, int> dic; void init() { dic.clear(); dic.insert(mp("one", (1 * 1 % 100))); dic.insert(mp("two", (2 * 2 % 100))); dic.insert(mp("three", (3 * 3 % 100))); dic.insert(mp("four", (4 * 4 % 100))); dic.insert(mp("five", (5 * 5 % 100))); dic.insert(mp("six", (6 * 6 % 100))); dic.insert(mp("seven", (7 * 7 % 100))); dic.insert(mp("eight", (8 * 8 % 100))); dic.insert(mp("nine", (9 * 9 % 100))); dic.insert(mp("ten", (10 * 10 % 100))); dic.insert(mp("eleven", (11 * 11 % 100))); dic.insert(mp("twelve", (12 * 12 % 100))); dic.insert(mp("thirteen", (13 * 13 % 100))); dic.insert(mp("fourteen", (14 * 14 % 100))); dic.insert(mp("fifteen", (15 * 15 % 100))); dic.insert(mp("sixteen", (16 * 16 % 100))); dic.insert(mp("seventeen", (17 * 17 % 100))); dic.insert(mp("eighteen", (18 * 18 % 100))); dic.insert(mp("nineteen", (19 * 19 % 100))); dic.insert(mp("twenty", (20 * 20 % 100))); dic.insert(mp("a", 1)); dic.insert(mp("both", 4)); dic.insert(mp("another", 1)); dic.insert(mp("first", 1)); dic.insert(mp("second", 4)); dic.insert(mp("third", 9)); }
string ss; int a[maxn], cnt;
int main() { ios::sync_with_stdio(false); init(); while (getline(cin, ss)) { cnt = 0; stringstream st(ss.substr(0, ss.length() - 1)); string temp; while (st >> temp) { transform(all(temp), temp.begin(), ::tolower); if (dic.count(temp) != 0) { a[cnt++] = dic[temp]; } } sort(a, a + cnt);
int flag = 0; int i = 0; for (; i < cnt; i++) { if (a[i] == 0) continue; flag = 1; cout << a[i]; i++; break; } if (flag == 0) { cout << 0 << endl; continue; } for (i; i < cnt; i++) { cout << setw(2) << setfill('0') << a[i]; }
cout << endl; } }
|