zoukankan      html  css  js  c++  java
  • hdu4639Hehe

    http://acm.hdu.edu.cn/showproblem.php?pid=4639

    统计连续he的数量恰为斐波序列  不同块进行相乘

     1 #include <iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<algorithm>
     5 #include<stdlib.h>
     6 #define mod 10007
     7 using namespace std;
     8 char ss[11000];
     9 int f[11000];
    10 int main()
    11 {
    12     int t,i,k,kk=0;
    13     cin>>t;
    14     f[1] = 1;f[2] = 2;
    15     for(i = 3; i <= 10086 ; i++)
    16     f[i] = (f[i-1]%mod+f[i-2]%mod)%mod;
    17     while(t--)
    18     {
    19         cin>>ss;kk++;
    20         k = strlen(ss);
    21         int g = 0,s=1;
    22         for(i = 0 ; i < k ;i++)
    23         {
    24             if((i+1)<k&&ss[i]=='h'&&ss[i+1]=='e')
    25             {
    26                 g++;
    27                 i++;
    28                 continue;
    29             }
    30             else if(g!=0)
    31             {
    32                 s=(s*f[g])%mod;
    33                 g=0;
    34             }
    35         }
    36         if(g)
    37         s = (s*f[g])%mod;
    38         printf("Case %d: ",kk);
    39         cout<<s<<endl;
    40     }
    41     return 0;
    42 }
    View Code
  • 相关阅读:
    面向对象
    Vue + webpack 项目实践
    配置webstorm监听less时时转换
    delegate事件代理
    JS for 循环
    JS while 循环
    JS switch 分支语句
    JS if 判断
    JS 运算符
    JS typeof() parseInt() parseFloat()
  • 原文地址:https://www.cnblogs.com/shangyu/p/3236166.html
Copyright © 2011-2022 走看看