题意大致如下:屌丝找女神聊天,女神回了一句 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. !important 的绝对控制样式

    <head> <style type="text/css"> div{background-color: blue !important;} </st ...

  2. shutil 模块

    import shutil #用于简化文件操作的模块 # f1 = open(r"D:\上海python全栈4期\day20\7.shutil模块.py","rb&quo ...

  3. netty]--最通用TCP黏包解决方案

    netty]--最通用TCP黏包解决方案:LengthFieldBasedFrameDecoder和LengthFieldPrepender 2017年02月19日 15:02:11 惜暮 阅读数:1 ...

  4. flask项目结构(一)mariadb

    简介: 本文主要是根据自己所学,创建一个flask项目,使用sqlalchemy,alembic,mariadb,bootstrap,APScheduler,selenium,request…………技 ...

  5. 【阿圆实验】Grafana HA高可用方案

    一.实现Grafana高可用 1.Grafana实现高可用性有两步: >>使用共享数据库存储仪表板,用户和其他持久数据>>决定如何存储会话数据. 2.Grafana高可用部署图 ...

  6. jq demo--横向+展开菜单,支持m站

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  7. CPU使用率过高分析方法

    项目过程中发现,应用服务器经常会出现CPU使用率较高的情况,需要定位出具体代码问题. 1.用top命令,根据CPU使用率排序,找出消耗cpu最高的进程 2.找出该进程下消耗CPU最高的线程(命令:to ...

  8. maven3.5.0在win10中的安装及环境变量配置

    1.maven的下载地址http://maven.apache.org/download.cgi.如下图,下载apache-maven-3.5.0-bin.zip 2.解压缩到自己指定的文件下,mav ...

  9. java中coroutine使用

    链接1:http://jm.taobao.org/2010/09/17/326/ 链接2:https://www.jianshu.com/p/0f1a6943eab5

  10. 前端select动态加载

    <select id ="ycode" cssclass="form-control selectpicker" name="ydljgId&q ...