codefoces round193a

July 25, 2013
CodeForces

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


/*
ID: zypz4571
LANG: C++
TASK: 193a.cpp
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
const int dir[8][2] = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{-1,1},{1,-1},{1,1}};
using namespace std;
char a[2222];
int main ( int argc, char *argv[] )
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    int n; cin>>n; 
    cin>>a+1;
    int len = strlen(a+1);
    long long ans(0);
    for (int i = 1; i+n<=len; i+=n) {
        if(a[i+n-1]==a[i+n-2]&&a[i+n-2]==a[i+n-3]) ans++;
    }
    cout<<ans<<endl;
        return EXIT_SUCCESS;
}                /* ----------  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.

comments powered by Disqus