Skip to content

服务器托管,北京服务器托管,服务器租用-价格及机房咨询

Menu
  • 首页
  • 关于我们
  • 新闻资讯
  • 数据中心
  • 服务器托管
  • 服务器租用
  • 机房租用
  • 支持中心
  • 解决方案
  • 联系我们
Menu

HDU 5351 MZL’s Border(规律)

Posted on 2023年5月6日 by hackdl

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 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
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

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

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

 

点击打开链接

import java.util.Scanner;
import java.math.BigInteger;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        BigInteger[] a=new BigInteger[1055];
        BigInteger[] b=new BigInteger[1055];
        a[1]=BigInteger.valueOf(1);
        a[2]=BigInteger.valueOf(2);
        for(int i=3;i0)
        {
            N--;
            int n=sc.nextInt();
            BigInteger m = sc.nextBigInteger();

            for(int i=1;i=0 )
                {

                     System.out.println((m.subtract(a[i-1])).mod(BigInteger.valueOf(258280327)));
                     break;
                }

            }
        }
    }
}

服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net

Related posts:

  1. 陕西emobile云主机:稳定可靠的服务器托管方案
  2. 昆明优质XP服务器托管服务,稳定可靠
  3. idc北京地址
  4. 服务器托管——独享与共享的比较
  5. 天津网吧云服务器托管:高效稳定的网络服务

服务器托管,北京服务器托管,服务器租用,机房机柜带宽租用

服务器托管

咨询:董先生

电话13051898268 QQ/微信93663045!

上一篇: HDU 5360 Hiking(优先队列)
下一篇: 华为Java机试题

最新更新

  • 五月学习之keepalived 软件简介
  • Cibersort免疫浸润的在线分析及R语言代码实现
  • 阿里云的认证最有几个等级?考试费用是多少?
  • 京东APP百亿级商品与车关系数据检索实践 | 京东云技术团队
  • 【Hello Network】TCP协议 TCP协议 确认应答机制 (ACK) 超时重传机制 连接管理机制 流量控制 滑动窗口 拥塞控制 延时应答 捎带应答 面向字节流 粘包问题 TCP的异常情况 TCP小结 基于TCP的应用层协议

随机推荐

  • 北京服务器租用年费价格调查报告
  • 南阳云服务器托管服务:稳定高效的选择
  • 高效便捷的虚拟手机服务器租用服务
  • idc机房租用1个机柜报价
  • “高效可靠的托管服务器中心服务R

客服咨询

  • 董先生
  • 微信/QQ:93663045
  • 电话:13051898268
  • 邮箱:dongli@hhisp.com
  • 地址:北京市石景山区重聚园甲18号2层

友情链接

  • 服务器托管
  • 服务器租用
  • 机房租用托管
  • 服务器租用托管
©2023 服务器托管,北京服务器托管,服务器租用-价格及机房咨询 京ICP备13047091号-8