1001 Exponentiation

Problem Link

/* package whatever; // don’t place package name! */

import java.util.*;
import java.math.*;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{Scanner sc=new Scanner(System.in);
while(sc.hasNext())
{
BigDecimal bas=sc.nextBigDecimal();
int n=sc.nextInt();
BigDecimal num=bas.pow(n);
String st=new String(num.toPlainString());

int str=0;
while(st.charAt(str)==’0′)
str++;
int end=st.length()-1;
while(st.charAt(end)==’0′)
end–;
if(st.charAt(end)==’.’)
end–;
System.out.println(st.substring(str,end+1));

}
// your code goes here
}
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s