题意大致如下:屌丝找女神聊天,女神回了一句 hehe ,而我们都知道 Hehe 有两个意思,一个就是 Hehe ,另外一个则是 wqnmlgb (我去年买了个表) ,所以屌丝很纠结,于是开始思考到底女神是什么意思,现在屌丝想知道女神的一句话究竟有多少种意思?

这题的定位是签到题,很水。

从题目给的第四组测试数据 eheheheh ,对应的答案是 3 种情况,由此分析(我下面用 H 表示 he ,用 W 表示 wqnmlgb):
第三组数据:   eHHHh

可能的情况就是:eWHh   eHWh eHHHh 这三种。

下面进一步扩展一下,将第三组数据简化成 HHH ,因为开始和结尾的两个字符不是会有歧义的 Hehe 。所以我们可以推出下表:

H                   ---               1

HH                 ---               2

HHH               ---               3

HHHH             ---               5

HHHHH           ---               8

从这五组数据就能看出,连续的 H 能造成的歧义是斐波那契数列。然后,就是讨论不连续的 H 。看下面这个例子:

ahehebhehe

这个例子的答案很显然是 4 。这个数据简化一下变成 HHbHH 。注意,这里由于不连续,所以中间的 b 不能删掉。所以四种情况就是 HHbW   WbHH   WbW   HHbHH 。分析下就可以得出 4 是由 1 * 2 * 2 得来的。因为每一段 H 都可以独立的变化,互相不影响。由之前得到的斐波那契数列可以知道,HH 可以造成 2 种意思,然后因为有两组 HH ,且互相独立。所以直接相乘。

然后题目分析到这里,就已经非常明朗了,我们需要做的就是把所有连续 H 造成的歧义数相乘就OK了。所以,用预处理斐波那契数列,然后扫一趟输入的字符串就能得出答案了。

P.s :需要注意答案要对 10007 取模。

附AC代码:

   1: #include <stdio.h>

   2: #include <math.h>

   3: #include <iostream>

   4: #include <cstdarg>

   5: #include <algorithm>

   6: #include <string.h>

   7: #include <stdlib.h>

   8: #include <string>

   9: #include <list>

  10: #include <vector>

  11: #include <map>

  12: #define LL long long

  13: #define M(a) memset(a, 0, sizeof(a))

  14: using namespace std;

  15:  

  16: void Clean(int count, ...)

  17: {

  18:     va_list arg_ptr;

  19:     va_start (arg_ptr, count);

  20:     for (int i = 0; i < count; i++)

  21:         M(va_arg(arg_ptr, int*));

  22:     va_end(arg_ptr);

  23: }

  24: int buf[10089];

  25:  

  26: void Pre()

  27: {

  28:     buf[0] = 1;

  29:     buf[1] = 2;

  30:     for (int i = 2; i <= 10087; i++)

  31:     {

  32:         buf[i] = (buf[i - 1] + buf[i - 2]) % 10007;

  33:  

  34:     }

  35:     return ;

  36: }

  37:  

  38: int main()

  39: {

  40:     char hehe[10099];

  41:     Clean(2, buf, hehe);

  42:     Pre();

  43:     int T;

  44:     scanf("%d", &T);

  45:     for (int cnt = 1; cnt <= T; cnt++)

  46:     {

  47:         scanf("%s", hehe);

  48:         printf("Case %d: ", cnt);

  49:         int res = 1;

  50:         int tmp = 0;

  51:         for (int i = 0; i < strlen(hehe); i++)

  52:         {

  53:             if (hehe[i] == 'h')

  54:             {

  55:                 while (hehe[i] == 'h' && i < strlen(hehe))

  56:                 {

  57:                     if (hehe[i + 1] == 'e' && hehe[i + 2] == 'h' && hehe[i + 3] == 'e')

  58:                         tmp += 1;

  59:                     else

  60:                     {

  61:                         res *= buf[tmp];

  62:                         res %= 10007;

  63:                         tmp = 0;

  64:                         break;

  65:                     }

  66:                     i += 2;

  67:                 }

  68:             }

  69:         }

  70:         res *= buf[tmp];

  71:         res %= 10007;

  72:         printf("%d\n", res);

  73:     }

  74:     return 0;

  75: }

HDU 4639 Hehe 2013 Multi-University Training Contest 4的更多相关文章

  1. HDU 4639 Hehe (2013多校4 1008 水题)

    Hehe Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  2. hdu 4930 Fighting the Landlords--2014 Multi-University Training Contest 6

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 Fighting the Landlords Time Limit: 2000/1000 MS ...

  3. HDU 6143 - Killer Names | 2017 Multi-University Training Contest 8

    /* HDU 6143 - Killer Names [ DP ] | 2017 Multi-University Training Contest 8 题意: m个字母组成两个长为n的序列,两序列中 ...

  4. HDU 6074 - Phone Call | 2017 Multi-University Training Contest 4

    看标程的代码这么短,看我的.... 难道是静态LCA模板太长了? /* HDU 6074 - Phone Call [ LCA,并查集 ] | 2017 Multi-University Traini ...

  5. HDU 6068 - Classic Quotation | 2017 Multi-University Training Contest 4

    /* HDU 6068 - Classic Quotation [ KMP,DP ] | 2017 Multi-University Training Contest 4 题意: 给出两个字符串 S[ ...

  6. HDU 6076 - Security Check | 2017 Multi-University Training Contest 4

    /* HDU 6076 - Security Check [ DP,二分 ] | 2017 Multi-University Training Contest 4 题意: 给出两个检票序列 A[N], ...

  7. HDU 6071 - Lazy Running | 2017 Multi-University Training Contest 4

    /* HDU 6071 - Lazy Running [ 建模,最短路 ] | 2017 Multi-University Training Contest 4 题意: 四个点的环,给定相邻两点距离, ...

  8. HDU 6078 - Wavel Sequence | 2017 Multi-University Training Contest 4

    /* HDU 6078 - Wavel Sequence [ DP ] | 2017 Multi-University Training Contest 4 题意: 给定 a[N], b[M] 要求满 ...

  9. HDU 6070 - Dirt Ratio | 2017 Multi-University Training Contest 4

    比赛时会错题意+不知道怎么线段树维护分数- - 思路来自题解 /* HDU 6070 - Dirt Ratio [ 二分,线段树 ] | 2017 Multi-University Training ...

随机推荐

  1. 方便好用的 Idea mybatis 插件 MyBatisCodeHelper

    优点: 1.mapper文件(即表对应的dao)与xml文件自由切换,方便代码评审: 2.自动代码生成功能提高开发效率,mysql数据库创建好表结构,写完 pojo(注意字段类型要统一用对象类型!), ...

  2. Cyclic Components CodeForces - 977E(DFS)

    Cyclic Components CodeForces - 977E You are given an undirected graph consisting of nn vertices and  ...

  3. laravel模型中设计使用单选按钮的方法:

    模型中写入: const SEX_UN = 10;//未知: const SEX_BOY = 20;//男 const SEX_GRIL = 30;//女 public function sex($i ...

  4. linux nginx 安装防火墙ngx_lua_waf

    ngx_lua_waf是一款开源的 基于 ngx_lua的 web应用防火墙 github地址是  https://github.com/loveshell/ngx_lua_waf 安装流程如下 1 ...

  5. System.properties

    win: len:54java.runtime.name=Java(TM) SE Runtime Environment   sun.boot.library.path=D:\Java\jdk1.8. ...

  6. 使用GCD控制网络请求

    当,当山峰没有棱角的时候 当河水不再流 当时间停住日夜不分 当天地万物化为虚有!,,,,不好意思跑题了! 当我们在一个页面中需要进行多次网络请求才能满足页面所有的显示需要的时候,我们需要控制这些请求全 ...

  7. Android : alsa-lib 移植

    一.官网下载lib源码 网址:http://www.alsa-project.org/main/index.php/Download#alsa-lib 左击:Stable Release列表中的[1. ...

  8. 2.17 C++类与const关键字

    参考: http://www.weixueyuan.net/view/6348.html 总结: const成员变量的初始化只有唯一的一条途径:参数初始化表. const成员函数可以使用类中的所有成员 ...

  9. Creating and Destroying Objects

    Consider static factpry methods instead of construction 四个优点两个缺点 One advantage of static factory met ...

  10. MySQL:用户管理

    用户管理部分 一.数据库不安全因素 非授权用户对数据库的恶意存取和破坏: 数据库中重要或敏感的数据被泄露: 安全环境的脆弱性: 二.数据库安全的常用方法 用户标识和鉴别[使用口令鉴别]::该方法由系统 ...