import java.math.BigInteger; import java.util.Scanner; public class Main { public static BigInteger fib[] = new BigInteger[1005]; static BigInteger one = new BigInteger("1"); public static void fibm(){ fib[1] = fib[2] = one; for( int i = 3; i <= 1000; ++i){ fib[i] = fib[i-1].add(fib[i-2]); } } static BigInteger MOD = new BigInteger("258280327"); public static void main(String[] args) { Scanner cin = new Scanner(System.in); fibm(); int T; int n; T = cin.nextInt(); BigInteger m, res; while(T>0){ n = cin.nextInt(); m = cin.nextBigInteger(); int i; for( i = 1; i < 1000;i++){ if(m.add(one).compareTo(fib[i])<0) break; } res = m.subtract(fib[i-2]); res = res.mod(MOD); System.out.println(res); T--; } } }
时间: 2024-10-17 11:31:16