java to do
First with C ++ played table and finds the following rules:
If the answer is corresponding to n x, then the next corresponding to the different answers to n x + 1
Recursion relations are different answers f [n] = 4 * f [n-1] -f [n-2], thus sec java
import java.util.Scanner; import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); BigInteger[] arr=new BigInteger[300]; arr[0]=BigInteger.valueOf(4); arr[1]=BigInteger.valueOf(14); BigInteger x=BigInteger.valueOf(4); BigInteger z=BigInteger.valueOf(-1); for(int i=2;i<300;i++) { arr[i]=arr[i-1].multiply(x); BigInteger y=arr[i-2].multiply(z); arr[i]=arr[i].add(y); } int T; BigInteger n; T=in.nextInt(); while(T-->0) { n=in.nextBigInteger(); for(int i=0;;i++) { if(n.compareTo(arr[i])<=0) {System.out.println(arr[i]); break;} } } in.close(); } }