hdu 5455(字符串处理)】的更多相关文章

Fang Fang Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1317    Accepted Submission(s): 548 Problem Description Fang Fang says she wants to be remembered.I promise her. We define the sequence…
单词数 HDU 2072 字符串输入控制 题意 lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数.下面你的任务是帮助xiaoou333解决这个问题. 有多组数据,每组一行,每组就是一篇小文章.每篇小文章都是由小写字母和空格组成,没有标点符号,遇到#时表示输入结束. 每组只输出一个整数,其单独成行,该整数代表一篇文章里不同单词的总数. 解题思路 我的是使用map来进行统计的,确实比较慢了一些,因为输入的问题代码也写的比较垃圾.之后看了网上的…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=5455 Fang Fang Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 233    Accepted Submission(s): 110 Problem Description Fang Fang says she wants to be…
Fang Fang Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5455 Description Fang Fang says she wants to be remembered.I promise her. We define the sequence F of strings.F0 = ‘‘f",F1 = ‘‘ff",F2 = ‘‘cff",F…
Problem Description Fang Fang says she wants to be remembered.I promise her. We define the sequence F of strings.F0 = ‘‘f",F1 = ‘‘ff",F2 = ‘‘cff",Fn = Fn−1 + ‘‘f", for n > 2Write down a serenade as a lowercase string S in a circle,…
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5455 题意就是找出所给字符串有多少个满足题目所给条件的子串,重复的也算,坑点是如果有c,f以外的字符也是不满足条件的,还有我被坑了的地方就是当输入很多f的时候,我尽然脑抽的 认为这是不满足条件的,注意这两点就行了,直接暴力 #include<cstdio> #include<cstring> using namespace std; int main() { int t,i,j,x,y,k…
http://acm.hdu.edu.cn/showproblem.php?pid=4821 昨晚卡了非常久,開始TLE,然后优化了之后,由于几个地方变量写混.一直狂WA.搞得我昨晚都失眠了,,. 这几次hash军写错的变量--tmp=(j==m-1)?ah[j]:(ah[j]-ah[j-m]*base[m]);  外层循环变量是i,我写的字符串hash的几题都写成tmp=(i==0)? ah[j]:(ah[j]-ah[j-m]*base[m]); 二逼啊 题目大意: 给定一个字符串(最长10^…
/*普通的hsah 由于元素太多 空间很小..hash碰撞很厉害.30分*/ #include<iostream> #include<cstdio> #include<cstring> #include<map> #define maxn 100010 #define mod 2000007 #define hs 117 using namespace std; ],l1[maxn],l2[maxn]; ],c,s1[maxn][],s2[maxn][];…
Problem Description 哈利波特在魔法学校的必修课之一就是学习魔咒.据说魔法世界有100000种不同的魔咒,哈利很难全部记住,但是为了对抗强敌,他必须在危急时刻能够调用任何一个需要的魔咒,所以他需要你的帮助. 给你一部魔咒词典.当哈利听到一个魔咒时,你的程序必须告诉他那个魔咒的功能:当哈利需要某个功能但不知道该用什么魔咒时,你的程序要替他找到相应的魔咒.如果他要的魔咒不在词典中,就输出“what?” Input 首先列出词典中不超过100000条不同的魔咒词条,每条格式为: [魔…
题目大意:f[1]=f,f[2]=ff,f[3]=ffc,以后f[n]每增加1,字符串增加一个c.给出一个字符串,求最少有多少个f[]组成.(字符串首尾相连,比如:ffcf可看做cfff) 题目思路:判断多少个c,但是每个c之间必须有两个f,首尾的c也应判断首尾相连后两者之间的距离.坑点在与 1.给出的字符串中可能包含其它字符 2.严格按照gets()读入 3.若不含c,求有多少个f[2],若有多余补上一个f[1] 3.1.出题人神经病 #include<cstdio> #include<…
题意是检查一个字符串是否满足三个条件: 一.至少有一个元音字母.二.不能出现三个连续的元音或三个连续的辅音.三.除了 ee 和 oo 外不能出现两个连续相同字母. 若三个条件都能满足,该字符串满足条件,有一个条件不满足则该字符串不满足条件. 但是这道题的数据......一定有元音字母,长度一定不少于 3.省去很多麻烦...... 代码如下: #include <bits/stdc++.h> using namespace std; int main() { int len; bool f; s…
Sample InputSTARTfrom fiwohello difhmars riwosfearth fnnvklike fiiwjENDSTARTdifh, i'm fiwo riwosf.i fiiwj fnnvk!END Sample Outputhello, i'm from mars.i like earth! 给你字符串以及它的映射,提问任意一个映射它真实的字符串是什么 #include<stdio.h> #include<algorithm> #include&l…
题意:给一系列的输出和标准答案,比较二者是AC,PE或WA 字符串处理还是比较薄弱,目前没什么时间搞字符串专题,所以遇到一题就努力搞懂 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map> using namespace std; #def…
求字符串循环节,要求每前i个字符串前缀是否循环,有的话打印出来. 我对j=next[i]数组(未优化,从0开始,第一个为-1,)理解:字符s[i]的前面的字符串,最长的相同的前缀和后缀 的长度,因此,i+1-next[i+1]刚好是最小循环单位(如果next[i+1]%(i+1-next[i+1)==0)(假设不是最小的,那么相同前后缀必然不是最大), 而next[i+1]/(i+1-next[i+1])+1,是循环的个数(+1是加开头上那一段), -------------------i --…
题目大意: 希望找到连续的长为m*l的子串,使得m个l长的子串每一个都不一样,问能找到多少个这样的子串 简单的字符串hash,提前预处理出每一个长度为l的字符串的hash值 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <map> #include <set> using namespace std; #de…
一道水题,练练字符串的输入输出 #include <cstdio> #include <cstring> using namespace std; ] , s2[]; int get_num(char *s) { ] == ; ] == ; ] == ] == ; ] == ] == ; ] == ] == ; ] == ] == ; ] == ] == ; ] == ] == ; ] == ; ] == ; } int main() { // freopen("a.in…
Fang Fang says she wants to be remembered. I promise her. We define the sequence FF of strings. F0 = ‘‘f",F0 = ‘‘f", F1 = ‘‘ff",F1 = ‘‘ff", F2 = ‘‘cff",F2 = ‘‘cff", Fn = Fn−1 + ‘‘f", for n > 2Fn = Fn−1 + ‘‘f", fo…
http://acm.hdu.edu.cn/showproblem.php? pid=4850 题意:构造长度为n的字符序列.使得>=4的子串仅仅出现一次 事实上最长仅仅能构造出来26^4+4-1= 456979 的序列,大于该数的都是不可能的.构造方法.就是那种欧拉回路的序列,此题DFS会爆栈.手动扩展栈也能够AC...... 递归形式的開始WA了.没有细调就换非递归了,后来又想了想,尽管自己电脑上执行不了.可是先把长度按小的来.然后调试代码,然后在扩大,AC了,当时错在MOD,递归的MOD应…
题目链接 题意: 给出n(n<=3000)个字符串(长度<30,数字组成,肯能存在前导0), 问该序列最少可以分成多少个单调序列.可以转化成求相同字符串的个数的最大值 附上代码: /************************************************************************* > File Name: 1800.cpp > Author: Stomach_ache > Mail: sudaweitong@gmail.com…
#include <stdio.h> #include <string.h> void main() { ) { ] = {'\0'}; ] = {'\0'}; ; scanf("%s", &input1); int len1 = (int)strlen(input1); ] == '#') return; scanf("%s", &input2); int len2 = (int)strlen(input2); //对inp…
思路:对于每个字符,如果它能被替换一定要优先替换,其次再进行删除.遵循这个策略即可. 证明: 对于这题的第一个测试数据: abba addba 1 d b 当匹配到'b'  和 'd'时应该优先替换而不是删除'd',这样可以保证不删除掉有用的字符. AC代码 #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <utility> #…
题意是将所给算式求出结果. 用的方法非常麻烦,开始没考虑到零也需要处理,以为遇上零直接跳过即可,知道发现零可以占位,比如 one zero 值为 10 而不是 1…… 代码如下: #include <bits/stdc++.h> using namespace std; int main() { ],s2[]; int a1,a2; ) { a1 = a2 = ; while(scanf("%s",s1) && strcmp(s1,"+"…
还需要再消化一下这个算法.. 今天没有时间了,, 六级过了 就有大把时间 快活啊!#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<set> using namespace std; int getmin(string s) { int n=s.size(); int i,t; while(i<n && j<n…
题意:意思是有若干个飞行员,需要在扫帚上练习飞行,每个飞行员具有不同的等级,且等级高的飞行员可以当等级低的飞行员的老师,且每个飞行员至多有且只有一个老师和学生.具有老师和学生关系的飞行员可以在同一把扫帚上练习,并且这个性质具有传递性.即比如有A,B,C,D,E五个飞行员,且等级是A>B>C>D>E,那么可以使A当B的老师,B当C的老师,E当D的老师,那么A,B,C可以在同一扫帚上练习,D,E在同一把扫帚上练习,这样需要2把扫帚,而如果是A当B的老师,B当C的老师,C当D的老师,D当…
Fang Fang Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 945    Accepted Submission(s): 393 Problem Description Fang Fang says she wants to be remembered. I promise her. We define the sequence…
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-size: 10.5000pt } h1 { margin-top: 5.0000pt; margin-bottom: 5.0000pt; text-align: center; font-family: 宋体; color: rgb(26,92,200); font-weight: bold; fo…
HDU Today Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 26104    Accepted Submission(s): 6341 Problem Description 经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强.这时候,…
这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿; 题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了: http://acm.hdu.edu.cn/showproblem.php?pid=2629 #include <iostream> #include <string> using namespace std; int main() { int n,t; string home,a; cin>>n; ; k < n ; k++) { ci…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4622 题意:给定一个长度不超过2000的字符串,之后有不超过1e5次的区间查询,输出每次查询区间中不同的子串个数? 做法1:字符串hash 一般的做法就是模拟每段子串的长度L(从1到 len),这样时间复杂度为O(n^2);但是里面并没有计算子串比较是否相等以及存储的时间,而这段时间就是将字符串看成是“数字”,这样存储和比较的时间均降为O(1)了: 下面讲讲模板: 1.如何将字符串看成一个“高精度的…
Text Reverse                                                                                  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description Ignatius likes to write words in reverse way. Given…