Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<algorithm>
- #include<cctype>
- #include<cmath>
- #define long long long
- using namespace std;
- string ban = "ABSINTH BEER BRANDY CHAMPAGNE GIN RUM SAKE TEQUILA VODKA WHISKEY WINE";
- void upcase(string &str)
- {
- for (char &i : str)
- i = toupper(i);
- }
- bool numerical(string str)
- {
- for (const auto &i : str)
- if (i >= '0' && i <= '9')
- return 1;
- return 0;
- }
- long str2num(string str)
- {
- long res = 0;
- while (str.size()){
- res += (str[0]-'0')*pow(10, str.size()-1);
- str.erase(0, 1);
- }
- return res;
- }
- int main()
- {
- cin.tie(0)->sync_with_stdio(0);
- cout.tie(0)->sync_with_stdio(0);
- //freopen("barsrule.inp", "r", stdin);
- long n;
- cin >> n;
- //cin.ignore();
- long ans = 0;
- while (n--){
- string s;
- //getline(cin, s, '\n');
- cin >> s;
- upcase(s);
- if (numerical(s)){
- long tpr = str2num(s);
- if (tpr < 18 && tpr != 16)
- ++ans;
- }
- else{
- if ((long)ban.find(s) != -1)
- ++ans;
- }
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment