Topic links: https://nanti.jisuanke.com/t/A1541
Question is intended: to give you a L, L is not less than the minimum demand of N, so that there is a positive integer m satisfying the 2m (m + 1) = n (n + 1)
Analysis: This idea is no problem to see it simply (n + 1) directly from the playing table 2m (m + 1) = n, Law came to be found in front of a few is 3,20,119,696,4059
Try to find the law, if he will not find on the direct use of Linear Recurrence factor formula to violence enumerate successfully obtain recurrence formula is f (n) = 6f (n-1) -f (n-2) + 2;
import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); int T=cin.nextInt(); BigInteger[] fn=new BigInteger [1500]; BigInteger two=new BigInteger("2"); BigInteger six=new BigInteger("6"); BigInteger L; fn[1]=new BigInteger("3");fn[2]=new BigInteger("20"); for(int i=3;i<=1200;i++) { fn[i]=fn[i-1].multiply(six).subtract(fn[i-2]).add(two); } for(int i=0;i<T;i++) { L=cin.nextBigInteger(); for(int j=1;j<=1200;j++) { if(L.compareTo(fn[j])<=0) { System.out.println(fn[j]); break; } } } } }