UVA – 113 – Power of Cryoptography

  • ID : UVA – 113 – Power of Cryoptography
  • Submissions : Java – Accepted
  • Difficulty : Easy
  • Type : Simple Math, Lograithms
  • Time for Submission : 1 Hour
  • Solution Description :
    • this problem may trick you iwth it’s large input data set. but actually all what you have to do is use double for the 10^101 p and use the inverse equation that k = ( p ) ^ 1/n.
  • Problems :
    • take care to adjust the output precession for the approximation.
    • I’m still confused even after the submission about how the precession adjustment gives the correct answer and weather it needs to be rounded or truncated.
  • Code :

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			double n= in.nextDouble(), p = in.nextDouble();
			System.out.format("%.0f\n",Math.pow(p, 1/n));
		}
	}
}
Advertisements

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

%d bloggers like this: