| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
java大数呗~~附代码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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator