日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【47.92%】【hdu 5763】Another Meaning

發(fā)布時(shí)間:2023/12/18 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【47.92%】【hdu 5763】Another Meaning 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1440????Accepted Submission(s): 690


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 HintIn 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”.
Author FZU
Source 2016 Multi-University Training Contest 4

【題解】

設(shè)c[i]表示前i個(gè)字符能組成多少種不同意思。

c[0..lens]初值為1;

c[i] += c[i-1]-1 (不取其特殊意思);

c[i] += c[i-lenb] (如果存在。則取其特殊意思);

abcdefgh

efgh

對于這樣的輸入

c[4]代表的是不取特殊意思的。==1

然后從c[4]可以推到c[4+lenb]

即c[4+lenb]+=c[4];

可以理解為

abcd****

abcdefgh這兩種。

至于怎么取一個(gè)合適的位置做這樣的推導(dǎo)。KMP

【代碼】

#include <cstdio> #include <cstring>const int MAX_SIZE = 101000; const int MOD = 1000000007;int t; int f[MAX_SIZE],c[MAX_SIZE]; char s[MAX_SIZE], p[MAX_SIZE]; bool can[MAX_SIZE]; int lens, lenp;void init() {memset(f, 0, sizeof(f));memset(c, 0, sizeof(c));memset(can, false, sizeof(can)); }void input_data() {scanf("%s", s);scanf("%s", p);f[0] = 0; f[1] = 0;lens = strlen(s);lenp = strlen(p);for (int i = 1; i <= lenp - 1; i++){int j = f[i];while (j && (p[i] != p[j])) j = f[j];f[i + 1] = (p[j] == p[i] ? j + 1 : 0);}int j = 0;for (int i = 0; i <= lens - 1; i++){while (j && (p[j] != s[i]))j = f[j];if (p[j] == s[i]) j++;if (j == lenp)can[i - lenp + 1] = true;} }void get_ans() {for (int i = 0; i <= lens; i++)c[i] = 1;for (int i = 0; i <= lens; i++){if (i)c[i] = (c[i] + c[i - 1] - 1) % MOD;if (can[i])c[i + lenp] = (c[i+lenp] + c[i]) % MOD;} }void output_ans() {printf("%d\n", c[lens]); }int main() {//freopen("F:\\rush.txt", "r", stdin);scanf("%d", &t);for (int i = 1; i <= t; i++){printf("Case #%d: ", i);init();input_data();get_ans();output_ans();}return 0; }

轉(zhuǎn)載于:https://www.cnblogs.com/AWCXV/p/7632243.html

總結(jié)

以上是生活随笔為你收集整理的【47.92%】【hdu 5763】Another Meaning的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 蜜桃臀一区二区三区 | 日韩欧美理论 | a少妇| 吸咬奶头狂揉60分钟视频 | 在线观看成人一区 | 欧美中文字幕视频 | 人成亚洲| 午夜秋霞 | 国产一区二区在线观看视频 | 国产l精品国产亚洲区久久 午夜青青草 | 男女操网站 | 日本一级片免费看 | а√天堂中文在线资源8 | 双性人妖互交localhost | 国产亚洲精品aaaaaaa片 | 欧美一a一片一级一片 | 久久av网址| 久久人人超碰 | 亚洲欧美日韩高清 | 久久久久久久黄色片 | 校园sm主奴调教1v1罚视频 | 欧美呦呦 | 日本福利一区二区 | 日本国产三级xxxxxx | av观看网址| 色男人的天堂 | 桃谷绘里香在线观看 | 18禁网站免费无遮挡无码中文 | 葵司ssni-879在线播放 | 日日碰| 中文字幕在线视频免费观看 | 国产精品免费视频一区二区三区 | 成人欧美一区二区三区黑人一 | 亚洲第一页在线 | 成人精品亚洲人成在线 | 可以免费看黄的网站 | 国产盗摄一区二区三区在线 | 日韩免费视频观看 | 专业操老外 | 久久久国产精华液 | 国产精品久久久久三级无码 | 森林影视官网在线观看 | 337p亚洲精品色噜噜狠狠 | 深夜激情视频 | 成人激情免费 | 精品国产av鲁一鲁一区 | 国产成人啪精品午夜在线观看 | 香港日本韩国三级网站 | 欧洲最强rapper网站直播 | 欧美日韩一区二区在线观看 | 人妻一区二区视频 | 中文字字幕一区二区三区四区五区 | 尤物在线视频观看 | 亚洲图片在线播放 | 欧美日韩中文字幕一区二区 | 在线免费成人网 | 欧美激情一区二区三级高清视频 | 欧美亚洲在线观看 | 中文字幕人妻熟女人妻a片 麻豆91视频 | 综合精品在线 | 韩国三级视频在线 | 99热欧美| 美女黄色在线观看 | 另类中文字幕 | 人人爽久久涩噜噜噜网站 | 欧美性生活一区二区 | 国产亚洲电影 | 黄色小说在线免费观看 | 韩国一区二区在线观看 | 日韩a视频 | 亚洲国产日韩欧美在线观看 | 欧美美女一区二区 | 国产性猛交xxxⅹ交酡全过程 | 国产91精品久久久 | 五月婷婷爱爱 | 一区二区三区视频在线免费观看 | 久久无码人妻丰满熟妇区毛片 | av激情在线观看 | 亚洲精品国产精品国 | 久久久久久网站 | 男女视频在线 | 久色91 | 狠狠搞狠狠干 | 狠狠操在线播放 | 国产第一av| av在线色 | 最近中文字幕一区二区 | 韩国不卡av | 国产123区在线观看 91国产一区二区 | 欧美色图网址 | 亚洲第一视频 | 无码国产精品一区二区高潮 | 五月开心播播网 | 日本少妇电影 | 欧美成人黄色网 | 怡红院精品视频 | 五月激情啪啪 | 欧美日韩国产a | ass精品国模裸体欣赏pics |