日韩性视频-久久久蜜桃-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ò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 青草久久网| 超碰免费视 | 总裁憋尿呻吟双腿大开憋尿 | 毛片网站免费观看 | 男女激情免费网站 | 久久久久无码国产精品一区李宗瑞 | 夜夜天堂| 欧美午夜精品一区 | 久久久精品区 | 大地资源高清播放在线观看 | 婷婷五月色综合 | 在线免费观看高清视频 | 激情欧美一区二区三区精品 | 九色porny丨精品自拍视频 | 日韩三区在线 | 黄色在线免费播放 | 久久久久久久久久久影院 | 不卡福利视频 | 波多野结衣家庭主妇 | 久草精品在线观看视频 | 天堂av免费在线 | 亚洲精品国产精品国自产网站按摩 | 久久久久国产一区二区三区 | 国产免费黄色网址 | 美女少妇毛片 | 蜜臀国产AV天堂久久无码蜜臀 | 青青草成人免费视频 | 一区二区三区视频 | 成人作爱视频 | 久久久久久久久久久久久av | 草民午夜理伦三级 | 另类少妇人与禽zozz0性伦 | 久久av免费看 | 欧美一级片在线观看 | 亚洲乱码一区二区三区 | jizzjizz欧美69巨大 | 欧美激情在线一区 | 爱操在线 | 国产精品久久久久久人 | 亚洲图片综合区 | 岛国精品视频 | 久久精品电影 | 91人妻一区二区三区 | 99热这里只 | 日本成人免费在线 | 天天色天天干天天 | 91精品国产乱码久久久张津瑜 | 国产国语性生话播放 | 久久视频热 | 性xxxxxxxxx18欧美 | 91视频在线观看视频 | 日韩中出在线 | 午夜日韩福利 | 青青草免费公开视频 | 日韩r级在线观看 | 毛片内射 | 亚洲精品无码久久 | wwww在线观看| 婷婷综合六月 | 欧美女人天堂 | 鲁丝片一区二区三区 | 亚洲精品天天 | 日本少妇激情视频 | 色爱亚洲 | 激情综合文学 | 不卡av在线播放 | 国产欧美日韩综合精品一区 | 午夜影院男女 | 日不卡 | 美女作爱网站 | 国产精品69久久久久孕妇欧美 | 久热热| 国产免费又爽又色又粗视频 | 欧美激情偷拍 | 苍井空浴缸大战猛男120分钟 | 91九色国产在线 | 91九色蝌蚪视频 | 午夜av成人 | 亚洲天堂2020 | 成人婷婷 | 日韩视频在线观看二区 | 国产精品传媒麻豆hd | 日韩精品人妻一区二区三区免费 | 在线不卡一区 | 天天燥日日燥 | 欧美a网| 伊人7| 成人一级免费视频 | 国产无限制自拍 | 午夜老湿机 | 青青视频一区二区 | av成人免费在线观看 | 26uuu亚洲国产精品 | 日韩精品人妻无码一本 | 亚洲黄色免费网站 | 免费三片60分钟 | 新天堂网 | 婷婷色基地 | 欧美色炮 |