hdu5351 MZL's Border(规律题,java)】的更多相关文章

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud MZL's Border Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 905    Accepted Submission(s): 295 Problem Description As is known to all,…
[HDU 5351 MZL's Border]题意 定义字符串$f_1=b,f_2=a,f_i=f_{i-1}f_{i-2}$. 对$f_n$的长度为$m$的前缀$s$, 求最大的$k$满足$s[1]=s[m-k+1],s[2]=s[m-k+2]...s[k]=s[m]$ Solution 先列出前几个字符串 $f_3=ab,f_4=aba,f_5=abaab,f_6=abaababa,f_7=abaababaabaab$. 对于n,m. 假设$f_{n-1}$的长度大于等于$m$,那么相当于求…
MZL's Border Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 944    Accepted Submission(s): 306 Problem Description As is known to all, MZL is an extraordinarily lovely girl. One day, MZL was pl…
f[1] = 'b', f[2] = 'a', f[i] = f[i - 1] + f[i - 2] 斐波那契数列的字符串,给你n和m,前m位中,最长的前缀等于后缀的长度是多少.1≤n≤1000, 1≤m≤length(f[n]) 规律题,虽然我不知道为什么. import java.io.*; import java.util.*; import java.math.*; public class Main{ //Scanner cin = Scanner(System.in); static…
MZL's Border Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5351 Mean: 给出一个类似斐波那契数列的字符串序列,要你求给出的f[n]字符串中截取前m位的字符串s中s[1...i] = s[s.size()-i+1....s.size()]的最大长度. analyse: 过计算可以发现,b字符串的前缀都是相同的,所以只要求出m的LBorder就行,和n是无关的,打表找出规律,找出对应不同的m,LBorder的…
送气球 Time Limit: 2000/1000ms (Java/Others) Problem Description: 为了奖励近段时间辛苦刷题的ACMer,会长决定给正在机房刷题的他们送气球.N位ACMer的围成了一个圈,会长分别间隔1,2,3,4.......个ACMer送一个气球,请问是不是所有的ACMer都有气球呢? Input: 输入一个数字N(2≤N<1000000000),代表ACMer的人数. Output: 如果所有人都有,输出‘YES’,否则输出‘NO’. Sample…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 137047    Accepted Submission(s): 33211 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (…
Given an m x n chessboard where you want to place chess knights. You have to find the number of maximum knights that can be placed in the chessboard such that no two knights attack each other. Those who are not familiar with chess knights, note that…
题目难度:Medium 题目: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The solution set must not contain duplicate quadrup…
题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. 翻译: 给定一组整数,两个数字的返回索引,它们的和会等于一个特定…