Posted 07/31/2015Updated 07/19/2023 Semprathlon / Simfae Dean ACM-ICPC / Programinga minute read (About 156 words)2015 Multi-University Training Contest 51009 MZL’s Border字符串是可递归形式构造的,求解也是递归的;但是递归时划分的三种情况,最终并没有做好化归 12345678910111213141516171819202122232425262728293031import java.io.*;import java.util.*;import java.math.*;public class Main{ static BigInteger f[] = new BigInteger[1005]; public static void main(String[] args){ f[1] = new BigInteger("1"); f[2] = new BigInteger("2"); for(int i = 3; i <= 1001; i++) f[i] = f[i - 1].add(f[i - 2]); Scanner cin = new Scanner(System.in); int T = cin.nextInt(); int n; BigInteger m; for(int cas = 1; cas <= T; cas++){ n = cin.nextInt(); m = cin.nextBigInteger(); BigInteger mm = m.add(new BigInteger("1")); int p = 0; for(int i = 1; i <= 1001; i++){ if(f[i].compareTo(mm) > 0){ p = i; break; } } BigInteger ans = m.subtract(f[p - 2]); System.out.println(ans.mod(new BigInteger("258280327"))); } }}