JAVA大数类练手
2011-11-15 18:23:59

import java.io.*;

import java.math.BigInteger;

import java.util.*;

public class Main

public 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);

}

import java.math.BigInteger;

import java.util.*;

import java.io.*;

public class Main

public static void main(String args[])

{

Scanner in = new Scanner(System.in);

int test = in.nextInt();

while(test-- > 0)

{

int n;

n = in.nextInt();

BigInteger a = new BigInteger("4");

for(int i = 1; i < n; ++i)

a = a.multiply(BigInteger.valueOf(4));

System.out.println(a.subtract(BigInteger.valueOf(1)).pide(BigInteger.valueOf(3)));

}

}

import java.io.*;

import java.math.BigInteger;

import java.util.*;

public class Main

public static void main(String args[])

{

Scanner cin = new Scanner(System.in);

while(cin.hasNext())

{

BigInteger a = cin.nextBigInteger();

BigInteger b = cin.nextBigInteger();

if(a.equals(BigInteger.ZERO) && b.equals(BigInteger.ZERO))

break;

int flag = a.compareTo(b);

if(flag == -1)

System.out.println("a<b");

else if(flag == 0)

System.out.println("a==b");

else

System.out.println("a>b");

}

}

import java.math.BigInteger;

import java.util.*;

import java.io.*;

public class Main

public static void main(String args[])

{

Scanner in = new Scanner(System.in);

int n = in.nextInt();

for(int i = 1; i <= n; ++i)

{

BigInteger a = in.nextBigInteger();

BigInteger b = in.nextBigInteger();

System.out.println("Case " + i + ":");

System.out.println(a + " + " + b + " = " +ans);

}

}

import java.io.*;

import java.math.BigInteger;

import java.util.*;

public class Main

public static void main(String args[])

{

Scanner cin = new Scanner(System.in);

BigInteger a[] = new BigInteger[100];

while(cin.hasNext())

{

for(int i = 0; i <= 2; ++i)

a[i] = cin.nextBigInteger();

for(int i = 3; i <= 99; ++i)

System.out.println(a[99]);

}

}

import java.io.*;

import java.math.BigDecimal;

import java.util.*;

public class Main

public static void main(String args[])

{

Scanner cin = new Scanner(System.in);

while(cin.hasNext())

{

BigDecimal ans = cin.nextBigDecimal();

int n = cin.nextInt();

String res = ans.pow(n).stripTrailingZeros().toPlainString(); //整数去掉小数点和后面的0

if(res.startsWith("0")) //去掉前导0

{

res = res.substring(1);

}

System.out.println(res);

}

}

}