Wednesday, 12 February 2014

UVA sloved: problem number: 11448 - Who said crisis?

11448 - Who said crisis?
Time limit: 10.000 seconds 
 B. Who Said Crisis? 

Context

The company Assistance for Critical Moments (ACM) is helping other companies to overcome the current economical crisis. As experts in computing machinery, their job is to calculate the cost/benefit balance of the other companies. They receive two numbers, indicating the total amount of benefits and costs, and they have to compute the final balance.

The Problem

You have to solve the complex business problem of computing balances. You are given two positive integer numbers, corresponding to the benefits and the costs. You have to obtain the total balance, i.e., the difference between benefits and costs.

The Input

The first line of the input contains an integer indicating the number of test cases.
For each test case, there is a line with two positive integer numbers, A and B, corresponding to the benefits and the costs, respectively. Both numbers are between 0 and a googol (10100) to the power of a hundred.

The Output

For each test case, the output should consist of a line indicating the balance: A-B.

Sample Input

4
10 3
4 9
0 8
5 2

Sample Output

7
-5
-8
3

_________________________________________________________________


solution: 
import java.util.Scanner;
import java.math.BigInteger;

public class Main
{
public static void main(String[] args)
{
Scanner input= new Scanner(System.in);
BigInteger x,y;
int c,d;

c= input.nextInt();
d= 0;

while(c>d)
{
x= input.nextBigInteger();
y= input.nextBigInteger();
System.out.println(x.subtract(y));
d++;
}
}
}


No comments:

Post a Comment