HDU 5763 Another Meaning(多校4)

mysql数据目录迁移后表不存在_mysql 直接从date 文件夹备份表,还原数据库之后提示 table doesn`t exist的原因和解决方法... 补充:正常情况下,建议数据库备份最好用工具进行备份,通过拷贝数据库表进行数据迁移,不同的环境会出现各种不同的意外问题。背景:今天在整理一个网站的时候,操作系统由于系统自动更新导致一直出现系统蓝屏死机,唉,悲剧了,于是重新安装了系统 windows server 2008 enterprise 32bit。详情:系统安装完成后,重新配置之前那个网站,appache服务配好之后,再配置数据的时候是这样... 阅读详情

Another Meaning

Problem Description
As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”. 
Today, ?? is chating with MeiZi online, MeiZi sends a sentence A to ??. ?? is so smart that he knows the word B in the sentence has two meanings. He wants to know how many kinds of meanings MeiZi can express.
 

Input
The first line of the input gives the number of test cases T; T test cases follow.
Each test case contains two strings A and B, A means the sentence MeiZi sends to ??, B means the word B which has two menaings. string only contains lowercase letters.

Limits
T <= 30
|A| <= 100000
|B| <= |A|

 

Output
For each test case, output one line containing “Case #x: y” (without quotes) , where x is the test case number (starting from 1) and y is the number of the different meaning of this sentence may be. Since this number may be quite large, you should output the answer modulo 1000000007.
 

Sample Input
4 hehehe hehe woquxizaolehehe woquxizaole hehehehe hehe owoadiuhzgneninougur iehiehieh
 

Sample Output
Case #1: 3 Case #2: 2 Case #3: 5 Case #4: 1
Hint
In the first case, “ hehehe” can have 3 meaings: “*he”, “he*”, “hehehe”. In the third case, “hehehehe” can have 5 meaings: “*hehe”, “he*he”, “hehe*”, “**”, “hehehehe”.
题意:
给定两个字符串,问第二个串在第一个串中可以最多可以表现多多少种不同的意思
题解:
直接上KMP找出对于第一个字符串的Pos位置的前缀和第二个字符串相同的所有位置,直接dp就可以了,听说数据很水的样子。
HDUOJ不能用next关键字当做数组名,导致CE一发,以后记住了。
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <iomanip>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define LL long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const int Mod = 1000000007;
const double esp = 1e-6;
const double PI = 3.1415926535898;
const int INF = 0x3f3f3f3f;
using namespace std;

char s[100005],t[100005];
bool vis[100005];
int Next[100005];
LL dp[100005];

void getnext(){
    int i=0,j=-1;
    Next[0]=-1;
    while(t[i]!='\0'){
        if(j==-1||t[i]==t[j]){
            i++;
            j++;
            Next[i]=j;
        }
        else{
            j=Next[j];
        }
    }
}

void kmp(){
    memset(vis,false,sizeof(vis));
    int i = 0,j = 0;
    getnext();
    int len1=strlen(s),len2=strlen(t);
    while(i<len1){
        if(j==-1||s[i]==t[j]){
            i++;
            j++;
        }
        else
            j=Next[j];
        if(j>=len2){
             vis[i] = true;
             j = Next[j];
        }
    }
}
int main(){
    int n , z = 1;
    scanf("%d%*c",&n);
    while(n--){
        gets(s);
        gets(t);
        kmp();
        int len = strlen(s);
        int len2  = strlen(t);
        dp[0] = 1;
        for(int i=1;i<=len;i++){
            dp[i] = dp[i-1];
            if(vis[i]){
                dp[i] = (dp[i]+dp[i-len2])%Mod;
            }
        }
        printf("Case #%d: %lld\n",z++,dp[len]);
    }
    return 0;
}


零基础入门转录组数据可视化——绘制差异小提琴图(常规) 转录组数据可视化之一,先介绍相关基础知识,其次用实际案例为基础,由浅入深介绍差异小提琴图绘制的全过程,包括内容有相关代码和截屏。 阅读详情

相关推荐

深入解析BLheli电调固件与Dshot通讯协议:从原理到实践

本文深入解析了无人机动力系统的核心——BLheli电调固件与Dshot通讯协议。详细阐述了BLheli固件从经典版到BLheli_32的演进及其功能特性,并重点剖析了Dshot数字协议如何通过数据包和校验码实现更快、更准、更可靠的电机控制。文章还涵盖了双向Dshot遥测、实战配置与调参指南,帮助玩家充分释放无人机性能。

weixin_28273593的博客 434

解题报告:HDU 5763

Problem Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.  Today, ?? is chating with MeiZi online, Me

HyJoker的博客 1010

PCB压合原理与工艺全流程深度解析

PCB压合是多层印制电路板制造中的核心工序,其本质并非简单物理叠加,而是高分子树脂流动、玻璃布应力释放、铜箔热膨胀及界面能调控的协同过程。理解压合原理,需掌握温度-压力-时间三维曲线动态关系;优化工艺流程,须兼顾叠板精度、热压参数匹配与冷却策略;关键影响因素如半固化片(PP)选型、铜箔表面处理、设备温场均匀性、结构对称性、环境湿度及操作手法,共同决定层间结合力、翘曲度与孔壁质量。本文围绕PCB压合原理、工艺流程、关键影响因素三大维度展开,融合IPC标准、实测数据与产线案例,为工艺工程师、NPI人员及设备维护

weixin_29191081的博客 256

(HDU - 5763)Another Meaning

(HDU - 5763)Another Meaning As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”. Today, ?? is chating with MeiZi online, MeiZi se

The wind of freedom blows 479

宇树G1语音助手完整开发指南(上)——从零构建智能知识库对话系统

本文将详细介绍如何为宇树G1人形机器人开发一个,实现"唤醒 → 对话 → 查询 → 回复"的智能助手功能。

m0_47999117的博客 785

Android Update Engine 分析(三四)OTA 签名都支持哪些算法?

写了几十篇还没涉及到 OTA 签名算法细节,OTA 讨论群也很少问这个,毕竟签名算法纯理论的问题,一旦实现好就极少需要改动,只需要进行一些配置,准备好签名的秘钥和证书就可以了。限于签名的算法理论太过于抽象,本篇不讨论签名算法细节,但会总结一些签名操作。以及 Android OTA 包支持的签名算法。本文主要分析 Update Engine 中支持的签名算法,以及这些算法的操作实现(不涉及原理部分),并总结签名和验签使用的 key。

洛奇看世界 716

HDU 5763 Another Meaning

Problem Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.  Today, ?? is chating with MeiZi online, Me

Occult 505

海康VisionMaster与西门子Smart 200进行S7通信

海康VisionMaster与西门子Smart 200进行S7通信

haier123888的博客 8180

(HDU 5763)Another Meaning <KMP + dp> 多校训练4

Another Meaning As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”. Today, ?? is chating with MeiZi online, MeiZi sen

STILLxjy 568

把 ABAP Smart Form 输出变成可直接下载的 PDF 二进制:OTF 到 XSTRING 的一条龙实践

SAP Smart Forms 生成 PDF 的实用方案:通过 OTF 格式转换实现高效输出。Smart Forms 本身不直接生成 PDF,而是输出 OTF 格式数据,需通过 CONVERT_OTF 函数转换。本文提供两种实现路径:传统的 Spool 方式和更优的直接获取 OTF 方式,后者避免了 Spool 的维护负担。核心代码演示了如何通过设置 GETOTF 参数获取 OTF 数据,并转换为 PDF 二进制流,适用于前端下载、接口传输等场景。同时介绍了 SSF_OPEN/SSF_CLOSE 方法用于批

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 675

置顶必读(3) |《滚雪球学SpringBoot》· 高质量专栏介绍,你值得拥有!

《滚雪球学SpringBoot》 并不是普通的技术讲解合集,它是专为开发者精心设计的系统化学习路径。通过不断“滚动学习”,我们将带领你从基础入门到高阶应用,从理解每一行代码到设计和优化大规模分布式系统,最终帮助你成长为一位精通 spring架构 的工程师。

**My Coding Family** 15万+

【字符串 Hash】【DP】 HDU - 5763 Another Meaning【串二可用第二种意思替换,问串一这句话可能有几种含义】

【字符串 Hash】【DP】 HDU - 5763 Another Meaning【串s2可用第二种意思替换,问串一这句话可能有几种含义】 As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse...

Floraqiu的博客 423

C#上位机+YOLO实战:从环境搭建到实现首个目标检测(零基础入门)

/ YOLOv8的类别名称(共80类,对应COCO数据集)// ONNX推理会话// YOLOv8的输入宽度// YOLOv8的输入高度本文从技术选型、环境搭建到代码实现,详细介绍了如何将C#上位机与YOLOv8结合,实现基础的目标检测功能。整个过程避开了常见的坑点,同时对核心原理和代码逻辑进行了详细解析,希望能帮助零基础的开发者快速入门。实际上,C#上位机+YOLO的组合在工业领域有非常广泛的应用,本文的案例只是一个起点。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 791

hdu5763 多校4 Another Meaning【kmp+dp】

题意: 给一个字符串和一个单词,问单词在串中的组合数。思路: 看到题想到了dp+kmp,推了一个别扭的转移方程,结果因为脑抽没过。。。 回头看了题解,比自己推得简单好多,而且发现不用kmp优化也不会超时。dp[i] 表示0-i串的组合数, dp[0] = 1, dp[i] = dp[i-1], (i-len+1, i)串匹配时 dp[i] += dp[i-len];题目传送门#incl

lh的博客 344

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

2016多校联赛4A Another Meaning(hdu 5763)

Another Meaning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 266    Accepted Submission(s): 114 Problem Description As is known

overload1997 402

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

2016多校训练Contest4: 1001 Another Meaning hdu5763

Problem Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.  Today, ?? is chating with MeiZi online, Me

lqybzx的专栏 463

【动态规划】【KMP】HDU 5763 Another Meaning

题目链接:   http://acm.hdu.edu.cn/showproblem.php?pid=5763 题目大意:   T组数据,给两个字符串s1,s2(len<=100000),s2可以被解读成2种意思,问s1可以解读成几种意思(mod 1000000007)。 题目思路:   【动态规划】【KMP】   题目有点绕,看看样例就懂了。其实不用KMP直接用subs...

PHILIP0917的博客 185

(2016多校联赛)hdu 5763 Another Meaning

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5763 题目大意: 给你两个字符串a,b,其中b字符串有两种意思,a串中也许有包含b串,问a串总共能组合出几种意思。 解题思路: 很明确的,这种题可以用DP。 我们令dp[i]为第i位之前的串共有多少种意思,这样答案输出  dp[ a串的长度 ]  即可。 首先,到第

霞之丘诗羽的博客 1743

HDU5763 Another Meaning

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5763 【题意】给定A,B两个字符串,B串有两个含义,问A串可能有几个含义。 【分析】先用KMP求出B串在A串中的所有位置。假定构成B串需要n个字符,position[i]表示B串在A串中第i+1次出现的位置,dp[i]表示从串头到position[i],A串可能的含义数。那么对于j

dDarkdawn的博客 474

hdu 5763 Another Meaning(2016 Multi-University Training Contest 4——dp+kmp)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5763 Another Meaning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 802    Accepted

若忆_star 1153

hdu_5763_Another Meaning(dp)

题目链接:hdu_5763_Another Meaning 题意: 一个文本串A,一个模式串B,如果文本串含有模式串B,那么就能组合成多种意思,如下: In the first case, “ hehehe” can have 3 meaings: “*he”, “he*”, “hehehe”. In the third case, “hehehehe” can have 5 meaing...

weixin_30817749的博客 137

HDU 5763 Another Meaning 多校赛 (DP + KMP)

Another Meaning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1111    Accepted Submission(s): 518 Problem Description As is known

qq_18661257的专栏 623

HDU 5763 Another Meaning (kmp + dp)

Another Meaning 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5763 Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also mean...

weixin_30839881的博客 101

hdu 5763 Another Meaning

Problem Description As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”.  Today, ?? is chating with MeiZi online, MeiZ

zoro_n的博客 360

hdu5763 Another Meaning (DP+KMP)

思路: 令dp[i]表示到i结尾的字符串可以表示的不同含义数,那么考虑两种转移: 末尾不替换含义:dp[i - 1] 末尾替换含义:dp[i - |B|]  (A.substr(i - |B| + 1,|B|) = B) 那么对于末尾替换含义的转移,需要快速判断BB能不能和当前位置的后缀匹配,kmp或者hash判断即可。 复杂度:O(N) #include

围巾的ACM博客 879

hdu 5763 Another Meaning KMP+DP(多校)

题意: 一句话可能有两个意思,给出两个字符串A,B。B是双重意思的字符串,问A这个字符串可有几种意思?也就是说,把B串在A中替换成*,一共可以构造出几种? 例: hehehehe hehe 答案是5 分析: 这题当时是我做的,第一次next数组编译错误QAQ,第二次A了。 思路是:先KMP求出B串在A串中出现的位置,然后就想着用dp了。由于在A串中B串...

141

2016 多校 Multi-University Training Contest 4 Another Meaning

hdu 5763 Another Meaning 题意是说给你一句话和一个单词,这个单词有两种意思,问这句话可能有几种意思。 不是很好理解题目的意思。 一开始的想法是用kmp跑出所有匹配的位置,然后把匹配出来的区间全部存下来,之后合并互相覆盖的区间,然后去看每个区间可能有几个意思,然后把所有答案乘起来,这样子做很麻烦,而且求每个区间可能有几个意思也不好求,所以这个方法pass了。

oldFlag 336
上一篇: HDU 5774 Where Amazing Happens(多校4)
下一篇: Calculate S(n) (规律题)
哆啦AC梦
博客等级 码龄12年 13粉丝 87原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值