hdoj 1819 Bishops

其实,答案就是2(n - 1)。

写个大数而已。熟悉一下java的大数吧算是,很有用,却会忘……

import java.math.BigInteger;
import java.util.*;

public class Hdoj1819 {
	public static void main(String args[]) {
		BigInteger two = new BigInteger("2");
		BigInteger res;
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()) {
			BigInteger n;
			n = cin.nextBigInteger();
			if(n.equals(BigInteger.ONE)) {
				System.out.println("1");
				continue;
			}
			n = n.subtract(BigInteger.ONE);
			res = n.multiply(two);
			System.out.println(res);
		}
	}
}


你可能感兴趣的:(java,String,Class,import)