NYOJ45 棋盘覆盖

原题链接


import java.util.Scanner;
import java.math.BigInteger;

public class Main{
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		int m, k;
		BigInteger a;
		m = cin.nextInt();
		
		while(m-- > 0){
			k = cin.nextInt();
			a = BigInteger.ONE;
			for(int i = 1; i <= k; ++i)
				a = a.multiply(BigInteger.valueOf(2));
			a = a.multiply(a);
			a = a.subtract(BigInteger.valueOf(1)).divide(BigInteger.valueOf(3));
			System.out.println(a);
		}
	}
}


你可能感兴趣的:(NYOJ45,棋盘覆盖)