HDU 5351 MZL's Border(找规律+高精度)

MZL‘s Border

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

Total Submission(s): 895    Accepted Submission(s): 287

Problem Description

As is known to all, MZL is an extraordinarily lovely girl. One day, MZL was playing with her favorite data structure, strings.

MZL is really like Fibonacci Sequence,
so she defines Fibonacci Strings in
the similar way. The definition of Fibonacci Strings is
given below.

1) fib1=b

2) fib2=a

3) fibi=fibi?1fibi?2, i>2

For instance, fib3=ab, fib4=aba, fib5=abaab.

Assume that a string s whose
length is n is s1s2s3...sn.
Then sisi+1si+2si+3...sj is
called as a substring of s,
which is written as s[i:j].

Assume that i<n.
If s[1:i]=s[n?i+1:n],
then s[1:i] is
called as a Border of s.
In Borders of s,
the longest Border is
called as s‘ LBorder.
Moreover, s[1:i]‘s LBorder is
called as LBorderi.

Now you are given 2 numbers n and m.
MZL wonders what LBorderm of fibn is.
For the number can be very big, you should just output the number modulo 258280327(=2×317+1).

Note that 1≤T≤100, 1≤n≤103, 1≤m≤|fibn|.

Input

The first line of the input is a number T,
which means the number of test cases.

Then for the following T lines,
each has two positive integers n and m,
whose meanings are described in the description.

Output

The output consists of T lines.
Each has one number, meaning fibn‘s LBorderm modulo 258280327(=2×317+1).

Sample Input

2
4 3
5 5

Sample Output

1
2

Source

2015 Multi-University Training Contest 5

题目大意:

解题思路:

版权声明:本文为博主原创文章,未经博主允许不得转载。

HDU 5351 MZL's Border(找规律+高精度)

时间: 2024-10-07 06:33:11

HDU 5351 MZL's Border(找规律+高精度)的相关文章

hdu 5351 MZL&#39;s Border 打表+高精度

MZL's Border Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 462    Accepted Submission(s): 127 Problem Description As is known to all, MZL is an extraordinarily lovely girl. One day, MZL was pl

HDOJ 5351 MZL&#39;s Border 找规律

打出前i个串的kmp的fail指针: p: ab 0 0 0 p: aba 0 0 0 1 p: abaab 0 0 0 1 1 2 p: abaababa 0 0 0 1 1 2 3 2 3 p: abaababaabaab 0 0 0 1 1 2 3 2 3 4 5 6 4 5 p: abaababaabaababaababa 0 0 0 1 1 2 3 2 3 4 5 6 4 5 6 7 8 9 10 11 7 8 p: abaababaabaababaababaabaababaabaab

HDU 5351 MZL&#39;s Border(规律)

MZL's Border Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 835    Accepted Submission(s): 268 Problem Description As is known to all, MZL is an extraordinarily lovely girl. One day, MZL was p

HDU 5351——MZL&#39;s Border——————【高精度+找规律】

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

HDU 5351 MZL&#39;s Border(java 找规律)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5351 Problem Description As is known to all, MZL is an extraordinarily lovely girl. One day, MZL was playing with her favorite data structure, strings. MZL is really like Fibonacci Sequence, so she defin

多校-HDU 5351 MZL&#39;s Border 数学

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]) 规律题,虽然我不知道为什么. 1 import java.io.*; 2 import java.util.*; 3 import java.math.*; 4 public class Main{ 5 //Scanner cin = Scanner(System.i

HDU 4572 Bottles Arrangement(找规律,仔细读题)

题目 //找规律,123321123321123321…发现这样排列恰好可以错开 // 其中注意题中数据范围: M是行,N是列,3 <= N < 2×M //则猜测:m,m,m-1,m-1,m-2,m-2,……,2,2,1,1求出前m个数字的和就是答案. //发现案例符合(之前的代码第二天发现案例都跑不对,真不知道我当时眼睛怎么了) #include <iostream> #include<stdio.h> #include<string.h> #inclu

HDU 2147-kiki&#39;s game(博弈/找规律)

kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others) Total Submission(s): 9174    Accepted Submission(s): 5485 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his

[FJOI2007]轮状病毒 题解(dp(找规律)+高精度)

[FJOI2007]轮状病毒 题解(dp(找规律)+高精度) 标签:题解 阅读体验:https://zybuluo.com/Junlier/note/1335733 没什么好说的,直接把规律找出来,有两种规律(据说还有多种dp),再套个高精度 \(First\) \(f[1]=1,f[2]=5,f[i]=3×f[i-1]-f[i-2]+2\) 就直接写个高精+低精和高精×低精和高精-高精就行了 \(Second\) \(f[1]=1,f[2]=3,f[i]=f[i-1]+f[i-2]\) \(i