codefoces round193a

link: http://codeforces.com/contest/332/problem/A

 1 /*
 2 ID: zypz4571
 3 LANG: C++
 4 TASK: 193a.cpp
 5  */
 6 
 7 #include <iostream>
 8 #include <cstdio>
 9 #include <cstdlib>
10 #include <cstring>
11 #include <cmath>
12 #include <cctype>
13 #include <algorithm>
14 #include <queue>
15 #include <deque>
16 #include <queue>
17 #include <list>
18 #include <map>
19 #include <set>
20 #include <vector>
21 #include <utility>
22 #include <functional>
23 #include <fstream>
24 #include <iomanip>
25 #include <sstream>
26 #include <numeric>
27 #include <cassert>
28 #include <ctime>
29 #include <iterator>
30 const int INF = 0x3f3f3f3f;
31 const int dir[8][2] = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{-1,1},{1,-1},{1,1}};
32 using namespace std;
33 char a[2222];
34 int main ( int argc, char *argv[] )
35 {
36 #ifndef ONLINE_JUDGE
37 freopen("in.txt", "r", stdin);
38 #endif
39     ios::sync_with_stdio(false);
40     int n; cin>>n; 
41     cin>>a+1;
42     int len = strlen(a+1);
43     long long ans(0);
44     for (int i = 1; i+n<=len; i+=n) {
45         if(a[i+n-1]==a[i+n-2]&&a[i+n-2]==a[i+n-3]) ans++;
46     }
47     cout<<ans<<endl;
48         return EXIT_SUCCESS;
49 }                /* ----------  end of function main  ---------- */

However, I can not understand the problem's meanning at first although it is so easy in fact.

It is time to train myself reading some problem and grasp it as quickly as possible.

原文地址:https://www.cnblogs.com/liuxueyang/p/3213552.html