-
Notifications
You must be signed in to change notification settings - Fork 0
/
42.cpp
45 lines (43 loc) · 896 Bytes
/
42.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
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
bool hash[100010];
string get;
vector <string> s;
vector <string> :: iterator IT;
void Analysis()
{
for(int i = 0 ; i < get.size(); i ++){
int jump = 1;
if(get[i] == '"')
while(get[i + jump] != '"') jump ++;
s.push_back(get.substr(i + 1, jump - 1));
i += jump + 1;
}
}
int Sum_Digit(string & x)
{
int sum = 0;
for (int i = 0 ;i < (int)x.size(); i ++)
sum += x[i] - 'A' + 1;
return sum;
}
int main()
{
freopen("data.in","r",stdin);
ios::sync_with_stdio(false);
cin >> get; fclose(stdin);
Analysis();sort(s.begin(), s.end());
for (int i = 1; i <= 300 ; i ++)
hash[i * (i + 1) / 2] = 1;
int cut = 0;
for (IT = s.begin(); IT != s.end(); IT ++)
if (hash[Sum_Digit(* IT)]) cut ++;
cout << cut << endl;
fclose(stdout);
return 0;
}