Computer Programming Contest Preparation

ToolBox - Source for: 101/10113/a.java



/home/toolbox/public_html/solutions/101/10113/a.java
    1 import java.io.*;
    2 import java.util.*;
    3 import java.lang.Math;
    4 
    5 class a
    6 {
    7     public static void main(String args[])
    8     {
    9         Scanner s = new Scanner(System.in);
   10         int n;
   11         double p;
   12         try
   13             {
   14                 n = s.nextInt();
   15                 p = s.nextDouble();
   16             }
   17         catch(NoSuchElementException e)
   18             {
   19                 return;
   20             }
   21         while(true)
   22             {
   23                 try
   24                     {
   25                         double p_log = Math.log10(p);
   26                         double temp = p_log / n;
   27                         double k_abt = Math.pow(10,temp);
   28                         //System.out.println("n = " + n + " p = " + p);
   29                         //System.out.println("p_log: " + p_log + " temp: " + temp + " k_abt: " + k_abt);
   30                         k_abt += .5;
   31                         System.out.println((int)k_abt);
   32                         n = s.nextInt();
   33                         p = s.nextDouble();
   34                     }
   35                 catch(NoSuchElementException e)
   36                     {
   37                         return;
   38                     }
   39             }
   40     }
   41 }
   42