博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Revolving Digits[EXKMP]
阅读量:6412 次
发布时间:2019-06-23

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

Revolving Digits

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

Total Submission(s): 25512    Accepted Submission(s): 5585

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
 

 

Source
 

 

Recommend
zhoujiaqi2010   |   We have carefully selected several similar problems for you:            

如果比较两个字符串,就比较第一位不一样的,那我们就需要找出所有字符串和已知字符串的前缀公共部分。

在已知字符串后面载copy一份,然后做exkmp就行了。
需要注意的是,相同字符串只能出现一次,所以先求一遍循环节。
有一篇关于exkmp的ppt:http://wenku.baidu.com/view/79992a90bed5b9f3f80f1c16.html?from=search

#include
#include
using namespace std;const int N=2e5+10;int cas,_,Next[N];char T[N];void kmp(int l){ int i=0,j=-1;Next[i]=j; while(i
=p){ int j=(p-k+1>0)?p-k+1:0; while(k+j
=len) num2++; else if(T[Next[i]]>T[i+Next[i]]) num1++; else if(T[Next[i]]

 

转载于:https://www.cnblogs.com/shenben/p/6253935.html

你可能感兴趣的文章
提高企业虚拟化安全
查看>>
nagios监控私有服务过程
查看>>
列出对像属性,for(var i in obj)
查看>>
ELK中的redis的问题记录
查看>>
sed
查看>>
使用 commit tran 需注意
查看>>
mysql 利用explain查询优化
查看>>
三大通信运营商天猫电器城开店
查看>>
算法——时间复杂度和空间复杂度
查看>>
pull 与 fetch & merge
查看>>
希望大家多点祝福给家人
查看>>
Java8 十大新特性详解
查看>>
web.xml配置详解
查看>>
linux之sed详解
查看>>
Java基础学习总结(14)——Java对象的序列化和反序列化
查看>>
java 集合框架按字符串长度排序
查看>>
Maven学习总结(十)——使用Maven编译项目gbk的不可映射问题
查看>>
前端面试js(语法)
查看>>
读取本地HTML的小说阅读器应用源码项目
查看>>
手动安装K8s第七节:node节点部署-kube-proxy
查看>>