大数阶乘
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=28
代码如下:
- import java.io.*;
- import java.math.BigInteger;
- import java.util.*;
- public class Main
- {
- static void main(String args[])
- {
- Scanner cin = new Scanner(system.in);
- int n = cin.nextInt();
- BigInteger ans = BigInteger.ONE;
- for(int i = 1; i <= n; ++i)
- ans = ans.multiply(BigInteger.valueOf(i));
- System.out.println(ans);
- }
- }
棋盘覆盖
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=45
代码如下:
copy
- import java.math.BigInteger;
- import java.util.*;
- Scanner in = new Scanner(system.in);
- int test = in.nextInt();
- while(test-- > 0)
- {
- int n;
- n = in.nextInt();
- BigInteger a = new BigInteger("4");
- 1; i < n; ++i)
- a = a.multiply(BigInteger.valueOf(4));
- System.out.println(a.subtract(BigInteger.valueOf(1)).divide(BigInteger.valueOf(3)));
- }
- }
- }