Getting TLE in 112. a^b-b^a

Revision en1, by _Muhammad, 2018-04-24 17:20:55

My code getting TLE in sgu 112 problem. I am new to java programming so I am not understanding why my code is getting TLE. I also have submitted 3 code from github for this problem. They also got TLE. Now what should I do? Question link : http://codeforces.com/problemsets/acmsguru/problem/99999/112

My code :

//In the name of ALLAH

//package OverRiding;

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

public class Example1 {

    public static void main(String[]args) {


        Scanner cin = new Scanner( System.in );

        BigInteger bigA = cin.nextBigInteger();
        BigInteger bigB = cin.nextBigInteger();
        BigInteger aPowb, bPowa;
        aPowb = bigA.pow ( bigB.intValue() );
        bPowa = bigB.pow ( bigA.intValue() );

        BigInteger ans = aPowb.subtract ( bPowa );
        System.out.println(ans);


    }
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English _Muhammad 2018-04-24 17:20:55 927 Initial revision (published)