CodeForces 412E 手速题

//CodeForces 412E

 1 #include "iostream"
 2 #include "cstdio"
 3 #include "cstring"
 4 #include "algorithm"
 5 #include "vector"
 6 using namespace std;
 7 char str[1000010];
 8 int len;
 9 bool isl(char c)
10 {
11     if(c >= 'a' && c <= 'z')
12         return 1;
13     if(c >= 'A' && c <= 'Z')
14         return 1;
15     return 0;
16 }
17 
18 bool isn(char c)
19 {
20     if(c >= '0' && c <= '9')
21         return 1;
22     return 0;
23 }
24 
25 int main()
26 {
27     int i, j;
28     scanf("%s", str + 1);
29     len = strlen(str + 1);
30     __int64 res = 0, a, b;
31     for(i = 1; i <= len; ++i) {
32         if(str[i] == '@') {
33             a = b = 0;
34             for(j = i - 1; j >= 1; --j) {
35                 if(str[j] == '@' || str[j] == '.')
36                     break;
37                 if(isl(str[j]))
38                     ++a;
39             }
40             for(j = i + 1; j <= len && (isl(str[j]) || isn(str[j])); ++j);
41             if(str[j] == '.' && j != i + 1) {
42                 for(++j; j <= len && isl(str[j]); ++j) {
43                     ++b;
44                 }
45             }
46             res += a * b;
47         }
48     }
49     printf("%I64d\n", res);
50 }

 

posted @ 2015-02-24 18:15  AC_Phoenix  阅读(134)  评论(0编辑  收藏  举报