Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

java大数呗~~附代码

Posted by hutuxian at 2012-07-07 23:23:36 on Problem 2924
import java.math.BigInteger;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		for(int i = 1;i<=n;i++){
			int a = input.nextInt();
			int b = input.nextInt();
			BigInteger sum = BigInteger.valueOf(a+b);
			BigInteger num = BigInteger.valueOf(b-a+1);
			BigInteger big = BigInteger.valueOf(1);
			BigInteger cons = BigInteger.valueOf(2);
			big = big.multiply(sum).multiply(num).divide(cons);
			System.out.printf("Scenario #%d:\n",i);
			System.out.println(big);
			System.out.println();
		}
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator