First, solve the problem. Then, write the code. ” - John Johnson

It's not at all important to get it right the first time. It's vitally important to get it right the last time. ” - Andrew Hunt and David Thomas

Wednesday, July 16, 2014

Hashmat the Brave Warrior.

Author : Jisan
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-10055
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=996

Help: http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html

Code:

import java.math.BigInteger;
import java.util.Scanner;
public class Uva_10055 {
    public static void main(String args[]){
    Scanner J=new Scanner(System.in);
    BigInteger Big;
    while(J.hasNext()){
    BigInteger  a=new BigInteger (J.next());
    BigInteger  b=new BigInteger (J.next());
    if(a.compareTo(b)>0){
    Big=a.subtract(b);
    }else{
    Big=b.subtract(a);
    }
    System.out.println(Big);
    }
    }
}

No comments:

Post a Comment