博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu4333 扩展KMP
阅读量:6048 次
发布时间:2019-06-20

本文共 2435 字,大约阅读时间需要 8 分钟。

Revolving Digits

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 1802    Accepted Submission(s): 523

Problem 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 he will get the integer itself. For example, he can change 123 into 312, 231 and 123. Now he wanted to know how many different integers he can get that is less than the original integer, how many different integers he can get that is equal to the original integer and how many different integers he can get that is greater than the original integer. We will ensure that the original integer is positive and it has no leading zeros, but if we get an integer with some leading zeros by revolving the digits, we will regard the new integer as it has no leading zeros. For example, if the original integer is 104, we can get 410, 41 and 104.
 

 

Input
The first line of the input contains an integer T (1<=T<=50) which means the number of test cases. 
For each test cases, there is only one line that is the original integer N. we will ensure that N is an positive integer without leading zeros and N is less than 10^100000.
 

 

Output
For each test case, please output a line which is "Case X: L E G", X means the number of the test case. And L means the number of integers is less than N that we can get by revolving digits. E means the number of integers is equal to N. G means the number of integers is greater than N.
 

 

Sample Input
1 341
 

 

Sample Output
Case 1: 1 1 1
 
 
题目大意:给出一个数字,对这个数字进行操作:把最后一个放到最前面去。
求:进行完一轮后:有多少个  不同   的比它小,和它相等(包括自己),比它大的数
 
 
思路:
把原串复制一遍粘后面,然后进行一次扩展KMP求所有后缀与原串的最长公共前缀(方便比较大小),最后再做一个KMP去循环节(不同的数)
 
#include
#include
#include
#include
#include
int tt,t,x,z,q,e,i,j,n;int s[300011],a[300011],next[300011];char c;using namespace std;void Read(){ n=0; while(c=getchar(),c<'0'||c>'9'); s[++n]=c; while(c=getchar(),c>='0'&&c<='9')s[++n]=c;}void Exkmp(){ int i,len,l,k; len=0; for(i=2;i<=n;i++){ if(len
len){ len=i+a[i]-1; k=i; } } x=0; z=1; q=0; for(i=2;i<=n/2;i++){ if(a[i]>=n/2)z++; else{ if(s[i+a[i]]>s[1+a[i]])q++; if(s[i+a[i]]

 

转载于:https://www.cnblogs.com/applejxt/p/3801784.html

你可能感兴趣的文章
Oracle 12c 多租户 手工创建 pdb 与 手工删除 pdb
查看>>
shell初涉
查看>>
[浪子学编程][MS Enterprise Library]ObjectBuilder之创建策略祥解(二)
查看>>
关于云栖,有点无语的几个地方,管理能不能管?
查看>>
Windows线程的同步与互斥
查看>>
C#进阶系列——MEF实现设计上的“松耦合”(四):构造函数注入
查看>>
linux系统下安装两个或多个tomcat
查看>>
ProtoBuffer 简单例子
查看>>
iOS多线程开发系列之(一)NSThread
查看>>
微信小程序初体验(上)- 腾讯ISUX社交用户体验设计成员出品
查看>>
SAP WM Physical Inventory Method ST & PZ
查看>>
一次快速的数据迁移感悟
查看>>
《ELK Stack权威指南(第2版)》一3.6 Java日志
查看>>
C++流的streambuf详解及TCP流的实现
查看>>
《量化金融R语言初级教程》一2.5 协方差矩阵中的噪声
查看>>
相对/绝对路径,cd命令,mkdir/rmdir命令,rm命令
查看>>
tomcat中web.xml各配置项的意义
查看>>
Nodejs学习笔记(二):《node.js开发指南》代码中需要注意的几点
查看>>
Ztree异步加载自动展开节点
查看>>
反射操作公共成员变量
查看>>