HDU 5763 Another Meaning(多校4)

新硬盘到手,在统信UOS或麒麟系统上怎么认?保姆级教程从识别到挂载一步到位 本文提供新硬盘在统信UOS或麒麟KYLINOS系统上的完整配置指南,从识别物理硬盘到挂载全流程详解。通过终端命令如df和lsblk,帮助用户完成硬盘识别、分区、文件系统创建及挂载配置,确保新硬盘顺利投入使用。 阅读详情

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;
}


激光及激光器超全细节&原理总结 本文详细展示了激光、激光器、PN结、半导体激光器、光纤激光器的原理和应用; 阅读详情

相关推荐

四旋翼无人机控制算法实战:从PID到MPC的路径跟踪

本文深入探讨了四旋翼无人机控制算法的演进路径,从基础的PID控制到高级的MPC算法,详细解析了各类算法的原理、实现技巧及适用场景。通过实战案例对比分析,为开发者提供从算法选型到参数调优的全方位指导,助力提升无人机飞行控制的精度与稳定性。

weixin_29090917的博客 240

解题报告: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

VFIO框架源码分析(二十一)- IOMMUFD 模式下的 DMA 映射机制

在虚拟化 I/O 的世界里,无论上层管理面(如对象模型、设备绑定)如何重构,数据面最核心的任务始终未变——DMA 映射(DMA Mapping)。即如何建立 Guest Physical Address (GPA) 到 Host Physical Address (HPA) 的映射关系,并将其填入 IOMMU 的硬件页表中,使得直通设备能够正确访问虚拟机内存。在 Legacy VFIO (Type1) 时代,这一职责由承担,它通过ioctl 操作 Container。

qq_36071928的博客 1008

(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

MICROSAR OS:第一个task是如何执行起来的?

MICROSAR OS是Vector公司开发的符合AUTOSAR OS规范的实时操作系统。本文介绍MICROSAR

humu7733的博客 2570

Python 包安装报错:ERROR: No matching distribution found for xxx 的全面排查指南

本文全面解析Python包安装时常见的`ERROR: No matching distribution found for xxx`报错。从检查包名拼写、网络与镜像源配置,到深入分析Python版本、操作系统等环境兼容性问题,提供了从简到繁的排查步骤。文章还介绍了使用`pip debug`、`-v`参数等高级诊断工具,并给出了更换包管理器、使用Docker等终极解决方案,帮助开发者高效解决依赖安装难题。

p8q9r0的博客 896

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

第八篇 永磁同步电机控制-MTPA、MTPV

MTPA 的全称是 Maximum Torque Per Ampere,即 最大转矩电流比控制。核心思想:在输出特定转矩时,通过控制定子电流的幅值和相位(即d轴和q轴电流的分量),使得所需要的定子电流幅值最小。通俗理解:就是用“最省电”的方式产生所需要的力矩。就像开车时,找到一个最合适的油门和档位配合,使得在输出相同动力时,油耗最低。

深耕汽车电子:AUTOSAR、电机控制,助力数字汽车 1871

(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

【WRF数据介绍第二期】气象驱动场数据介绍及下载

【WRF数据介绍第二期】气象驱动场数据介绍及下载

WW、forever的博客 2160

原理和代码解读:用Diffusion Models高清图像修复(Image Inpainting)

在最近的Diffusion Models应用中,Image Inpainting+ControlNet/Lora等工作在模特衣服生成、家居场景重建等场景中得到了广泛的应用。这篇博客主要介绍Diffusion Models如何在修复高清图像的。

沉迷单车的追风少年 2497

【字符串 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

微信小程序 - 详细实现打开跳转第三方 H5 网页链接,在微信小程序内直接跳转打开第三方网站链接详细教程(支持跳转公众号文章等,直接复制代码即可)

小程序跳转h5,小程序-Taro小程序中打开h5页面链接,...小程序跳转h5链接(web-view)_微信小程序,小程序如何跳转h5页面,小程序跳转到第三方H5网页,微信小程序跳转第三方H5的方法,小程序-实现怎么跳转打开H5网页链接(或跳转至公众号文章,打开第三方网站,放校验文件,怎么配置业务域名,校验文件验证域名,把校验文件放到对面网站,别人的服务器也打不开没权限怎么放呢,勾选不校验合法域名,txt,打不开别人的网页怎么办,真机调试打不开,无法跳转,有什么其他办法不放校验文件吗,后台配置,怎么

🏆 前端领域优质创作者 3万+

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

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

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

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

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

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

【动态规划】【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
上一篇: 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、付费专栏及课程。

余额充值