UVA 10213(p336)----How Many Pieces of Land

来源:互联网 发布:c语言简易计算器 编辑:程序博客网 时间:2024/04/29 21:39
import java.io.*;import java.util.*;import java.math.*;public class Main{    static PrintWriter out = new PrintWriter(new  BufferedWriter(new OutputStreamWriter(System.out)));    public static void main(String args[]) throws IOException    {        Scanner cin=new Scanner(System.in);        int kase = cin.nextInt();        for(int c = 1; c <= kase; ++c)        {            BigInteger ans = BigInteger.valueOf(1);            String s = cin.next();            BigInteger n = new BigInteger(s);            BigInteger temp = new BigInteger(s);            temp = temp.multiply(temp.subtract(new BigInteger("1")));            temp = temp.divide(new BigInteger("2"));            ans = ans.add(temp);            temp = temp.multiply(n.subtract(new BigInteger("2")));            temp = temp.multiply(n.subtract(new BigInteger("3")));            temp = temp.divide(new BigInteger("12"));            ans = ans.add(temp);            System.out.println(ans);        }    }}

0 0
原创粉丝点击