题意大致如下:屌丝找女神聊天,女神回了一句 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. asp.net中javascript与后台c#交互

    asp.net中javascript与后台c#交互 作者:熊猫大叔 字体:[增加 减小] 类型:转载 时间:2015-10-23我要评论,出处:http://www.jb51.net/article/ ...

  2. java唯一ID生成

    有时我们不依赖于数据库中自动递增的字段产生唯一ID,比如多表同一字段需要统一一个唯一ID,这时就需要用程序来生成一个唯一的全局ID,然后在数据库事务中同时插入到多章表中实现同步. 在java中有个类工 ...

  3. LeetCode刷题 Flood Fill 洪水填充问题

    An  image is represented by a 2-D array of integers,each integers,each integer respresenting the sta ...

  4. bzoj1935

    题解: x升序排序 y离散化+树状数组 代码: #include<bits/stdc++.h> using namespace std; ; inline int read() { ,f= ...

  5. bzoj2946

    题解: 和poj1226差不多 把翻转去掉 然后不要忘记开大数组和二分的上限答案 代码: #include<bits/stdc++.h> using namespace std; type ...

  6. Python Django 之 直接执行自定义SQL语句(一)

    一.执行自定义SQL方法 1.Executing custom SQL directly      直接执行自定义SQL,这种方式可以完全避免数据模型,而是直接执行原始的SQL语句. 2.Manage ...

  7. mysql 内置函数和sql server 内置函数的区别

    以下函数均没有对参数做说明,使用的使用需要了解其参数内容 数据库 sql server mysql oracle 举例 获得当前系统时间 getdate() now() sysdate  注意不是函数 ...

  8. Cracking The Coding Interview 4.7_暂存

    //原文: // // You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds ...

  9. UGUI动态绑定事件

    using System.Collections.Generic;using UnityEngine;using UnityEngine.EventSystems;using UnityEngine. ...

  10. 图片 100%显示. img 全部显示.

    让每个图片 都铺满 ,同样的大小;    只要给 img 设置 固定的高度, 宽度就可以 了. ----------------------- html: <div class="co ...