import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
long arr[]=new long[41];
arr[1]=1;
arr[2]=5;
arr[3]=11;
for(int i=4;i<41;i++){
arr[i]= arr[i-1] + 4*arr[i-2] + 2*arr[i-3];
}
int cases=Integer.parseInt(br.readLine());
for(int i=0;i<cases;i++) {
int x = Integer.parseInt(br.readLine());
sb.append(arr[x]).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment