码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces 412E 手速题

时间:2015-02-24 18:39:07      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

//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 }

 

CodeForces 412E 手速题

标签:

原文地址:http://www.cnblogs.com/AC-Phoenix/p/4298842.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!