hdu4333】的更多相关文章

Revolving Digits   Description One day Silence is interested in revolving the digits of a positive integer. In the revolving operation, he can put several last digits to the front of the integer. Of course, he can put all the digits to the front, so…
/*注意注意:本题非hdu4333原题,而是简化版,原版有多组数据.但此代码在修改输入后依旧可以通过多组数据*/ 给出一个数字串,问有多少本质不同同构串比原串小,一样,大.同构串是指,对于原串S[1-N]通过旋转变成同构串S[i-N]+S[0-i-1].本质不同,指的是字符串不一样. 输入格式: 一行一个数字串 输出格式: 一行,输出本质不同的同构串比原串小,一样,大的三个数,用一个空格分隔开. 样例输入: 123123 样例输出: 0 1 2 数据范围: 数字串长度<=100000      …
慢慢研究可以发现,可以用扩展kmp来求.由于扩展kmp的next[]只有一部分,当前位子前面那部分和母串的后部分,所以可以将字符串复制接在后面一次. 先求如果next[]>0&&next[]!=len,那么只要考虑后面那位的大小比较.如果next[]>=len 那就是相同.如果next[]==0,就是没有相同的,直接比较开头. 这样做还是会超时,我tle无数发. 还要去掉重复的部分,题目要求不同的.所以求出循环部分,只要考虑一部分即可. //扩展kmp求最小循环节 int kk…
Revolving Digits Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1143    Accepted Submission(s): 335 Problem Description One day Silence is interested in revolving the digits of a positive inte…
题解: EX_KMP 先把串复制一遍放到后面 这样旋转就是每一个前缀了 然后做一个EX_KMP 然后看一下后一个字符谁大谁小 代码: #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; #define next ____next ; char s[N]; int T,next[N],cas; void getnext(char…
Revolving Digits Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24215    Accepted Submission(s): 5268 Problem Description One day Silence is interested in revolving the digits of a positive int…
hdu4333 /* 题意:字符串s[0..n-1],每次把最后一个字符放到前面,求形成的字符串比最初串分别小,相同,大于的个数 因为是为了练习扩展KMP所以肯定是扩展KMP, 为了循环方便,在后面复制字符串,求出next[]数组后, 如果next[i]>n那么肯定相等,如果小于就判断s[ next[i] ]和 s[ i+next[i] ]的大小判断 trick:题目求得是形成的不同的字符串的个数,可以知道相等的字符串肯定只有一个, 而从0..n-1,第二个next[i]大于n那么这个i就是该字…