题目链接:http://poj.org/problem?id=2406 题目大意:如果n%(n-next[n])==0,则存在重复连续子串,长度为n-next[n]. 例如: a b a b a b next:-1 0 0 1 2 3 4 next[n]==4,代表着,前缀abab与后缀abab相等的最长长度,这说明,ab这两个字母为一个循环节,长度=n-next[n]; #include <iostream> #inc…
Cyclic Nacklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15422 Accepted Submission(s): 6425 Problem Description CC always becomes very depressed at the end of this month, he has checked his…
题目描述 E.T. Inc. employs Maryanna as alien signal researcher. To identify possible alien signals and background noise, she develops a method to evaluate the signals she has already received. The signal sent by E.T is more likely regularly alternative. …
A. Arpa’s hard exam and Mehrdad’s naive cheat time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do. Me…
Milking Grid Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 7153 Accepted: 3047 Description Every morning when they are milked, the Farmer John's cows form a rectangular grid tha…
首先将扑克牌进行一次置换,然后分解出所有的循环节,所有循环节的扑克牌个数的最小公倍数即为答案 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define LL long long int n,k; LL d[850],ct; int vis[850]; int a[850]; int dfs(int x) { if(!vis[a[x]]) { ct++;…
Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 33178 Accepted: 13792 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "…