hdu4639 hehe ——斐波纳契数列,找规律

August 3, 2013
Hdu

link:http://acm.hdu.edu.cn/showproblem.php?pid=4639 refer to: http://blog.csdn.net/dongdongzhang_/article/details/9706259 http://www.cnblogs.com/wuhenqs/archive/2013/08/01/3230987.html


#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;

const int MOD = 10007;
char a[11111];
long long fi[11111];
int main(void)
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif
    ios::sync_with_stdio(false);
    int t; cin>>t;
    fi[0] = fi[1] = 1;
    for (int i = 2; i < 11111; ++i) fi[i] = (fi[i-1]+fi[i-2])%MOD;
    for (int i = 1; i <= t; ++i)
    {
        cin>>a; int len = strlen(a), cnt = 0, ans = 1;
        for (int j = 1; j < len; ++j)
        {
            if (a[j]=='e' && a[j-1]=='h')
            {
                ++j; cnt++;
            }
            else
            {
                ans = (ans*fi[cnt])%MOD; cnt = 0;
            }
        }
        ans = (ans*fi[cnt])%MOD;
        cout<<"Case "<<i<<": "<<ans<<endl;
    }

}

o(╯□╰)o

comments powered by Disqus