【大数问题】 HDOJ 5047 Sawtooth

比赛的时候因为没有输入挂的缘故用java A不了。。。。

import java.io.*;
import java.util.*;
import java.math.*;

class InputReader
{
	BufferedReader buf;
	StringTokenizer tok;
	InputReader()
	{
		buf = new BufferedReader(new InputStreamReader(System.in));
	}
	boolean hasNext()
	{
		while(tok == null || !tok.hasMoreElements()) {
			try{
				tok = new StringTokenizer(buf.readLine());
			} catch(Exception e) {
				return false;
			}
		}
		return true;
	}
	String next()
	{
		if(hasNext()) return tok.nextToken();
		return null;
	}
	int nextInt()
	{
		return Integer.parseInt(next());
	}
	long nextLong()
	{
		return Long.parseLong(next());
	}
	double nextDouble()
	{
		return Double.parseDouble(next());
	}
	BigInteger nextBigInteger()
	{
		return new BigInteger(next());
	}
}
public class Main
{

	public static void main(String[] args)
	{
		InputReader in = new InputReader();
		PrintWriter out = new PrintWriter(System.out);
		int t = in.nextInt();
		BigInteger ans, tt;
		for(int i = 1; i <= t; i++) {
			tt = in.nextBigInteger();
			ans = tt.multiply(tt).multiply(BigInteger.valueOf(8));
			tt = tt.multiply(BigInteger.valueOf(7));
			ans = ans.subtract(tt).add(BigInteger.ONE);
			out.println("Case #" + i + ": " + ans.toString());
		}
		out.close();
	}
}


你可能感兴趣的:(HDU)