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

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

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstdlib>
 4 #include <cstring>
 5 #include <cmath>
 6 #include <cctype>
 7 #include <algorithm>
 8 #include <queue>
 9 #include <deque>
10 #include <queue>
11 #include <list>
12 #include <map>
13 #include <set>
14 #include <vector>
15 #include <utility>
16 #include <functional>
17 #include <fstream>
18 #include <iomanip>
19 #include <sstream>
20 #include <numeric>
21 #include <cassert>
22 #include <ctime>
23 #include <iterator>
24 const int INF = 0x3f3f3f3f;
25 const int dir[8][2] = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{-1,1},{1,-1},{1,1}};
26 using namespace std;
27 
28 const int MOD = 10007;
29 char a[11111];
30 long long fi[11111];
31 int main(void)
32 {
33     #ifndef ONLINE_JUDGE
34     freopen("in.txt", "r", stdin);
35     #endif
36     ios::sync_with_stdio(false);
37     int t; cin>>t;
38     fi[0] = fi[1] = 1;
39     for (int i = 2; i < 11111; ++i) fi[i] = (fi[i-1]+fi[i-2])%MOD;
40     for (int i = 1; i <= t; ++i)
41     {
42         cin>>a; int len = strlen(a), cnt = 0, ans = 1;
43         for (int j = 1; j < len; ++j)
44         {
45             if (a[j]=='e' && a[j-1]=='h')
46             {
47                 ++j; cnt++;
48             }
49             else
50             {
51                 ans = (ans*fi[cnt])%MOD; cnt = 0;
52             }
53         }
54         ans = (ans*fi[cnt])%MOD;
55         cout<<"Case "<<i<<": "<<ans<<endl;
56     }
57 
58 }

o(╯□╰)o

posted on 2013-08-03 10:29  aries__liu  阅读(198)  评论(0编辑  收藏  举报