fork download
  1. import java.io.OutputStream;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.PrintWriter;
  5. import java.util.InputMismatchException;
  6. import java.io.IOException;
  7. import java.io.InputStream;
  8.  
  9. /**
  10.  * Built using CHelper plug-in
  11.  * Actual solution is at the top
  12.  *
  13.  * @author G. Guarnieri
  14.  */
  15. public class Main {
  16. public static void main(String[] args) {
  17. InputStream inputStream = System.in;
  18. OutputStream outputStream = System.out;
  19. InputReader in = new InputReader(inputStream);
  20. PrintWriter out = new PrintWriter(outputStream);
  21. FantasticDiscovery solver = new FantasticDiscovery();
  22. int testCount = Integer.parseInt(in.next());
  23. for (int i = 1; i <= testCount; i++) {
  24. solver.solve(i, in, out);
  25. }
  26. out.close();
  27. }
  28.  
  29. static class FantasticDiscovery {
  30. private static final double EPSILON = 1E-6D;
  31.  
  32. public void solve(int testNumber, InputReader in, PrintWriter out) {
  33. double p = in.readDouble();
  34. int c = in.readInt();
  35.  
  36. double low = 1D, high = 15D;
  37.  
  38. while (high - low > EPSILON) {
  39. final double mid = (low + high) / 2D;
  40. final double currentGrowth = mid * Math.pow(mid, c * mid);
  41.  
  42. if (currentGrowth > p) {
  43. high = mid;
  44. } else {
  45. low = mid;
  46. }
  47. }
  48.  
  49. final double outcome = (low + high) / 2D;
  50. out.printf("%.6f%n", outcome);
  51. }
  52.  
  53. }
  54.  
  55. /**
  56. * @author Egor Kulikov (kulikov@devexperts.com)
  57. * https://g...content-available-to-author-only...b.com/EgorKulikov/yaal/tree/master/lib/main/net/egork/io
  58. */
  59. static class InputReader {
  60. private InputStream stream;
  61. private byte[] buf = new byte[1024];
  62. private int curChar;
  63. private int numChars;
  64. private InputReader.SpaceCharFilter filter;
  65.  
  66. public InputReader(InputStream stream) {
  67. this.stream = stream;
  68. }
  69.  
  70. public int read() {
  71. if (numChars == -1) {
  72. throw new InputMismatchException();
  73. }
  74. if (curChar >= numChars) {
  75. curChar = 0;
  76. try {
  77. numChars = stream.read(buf);
  78. } catch (IOException e) {
  79. throw new InputMismatchException();
  80. }
  81. if (numChars <= 0) {
  82. return -1;
  83. }
  84. }
  85. return buf[curChar++];
  86. }
  87.  
  88. public int readInt() {
  89. int c = read();
  90. while (isSpaceChar(c)) {
  91. c = read();
  92. }
  93. int sgn = 1;
  94. if (c == '-') {
  95. sgn = -1;
  96. c = read();
  97. }
  98. int res = 0;
  99. do {
  100. if (c < '0' || c > '9') {
  101. throw new InputMismatchException();
  102. }
  103. res *= 10;
  104. res += c - '0';
  105. c = read();
  106. } while (!isSpaceChar(c));
  107. return res * sgn;
  108. }
  109.  
  110. public String readString() {
  111. int c = read();
  112. while (isSpaceChar(c)) {
  113. c = read();
  114. }
  115. StringBuilder res = new StringBuilder();
  116. do {
  117. if (Character.isValidCodePoint(c)) {
  118. res.appendCodePoint(c);
  119. }
  120. c = read();
  121. } while (!isSpaceChar(c));
  122. return res.toString();
  123. }
  124.  
  125. public boolean isSpaceChar(int c) {
  126. if (filter != null) {
  127. return filter.isSpaceChar(c);
  128. }
  129. return isWhitespace(c);
  130. }
  131.  
  132. public static boolean isWhitespace(int c) {
  133. return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
  134. }
  135.  
  136. public double readDouble() {
  137. int c = read();
  138. while (isSpaceChar(c)) {
  139. c = read();
  140. }
  141. int sgn = 1;
  142. if (c == '-') {
  143. sgn = -1;
  144. c = read();
  145. }
  146. double res = 0;
  147. while (!isSpaceChar(c) && c != '.') {
  148. if (c == 'e' || c == 'E') {
  149. return res * Math.pow(10, readInt());
  150. }
  151. if (c < '0' || c > '9') {
  152. throw new InputMismatchException();
  153. }
  154. res *= 10;
  155. res += c - '0';
  156. c = read();
  157. }
  158. if (c == '.') {
  159. c = read();
  160. double m = 1;
  161. while (!isSpaceChar(c)) {
  162. if (c == 'e' || c == 'E') {
  163. return res * Math.pow(10, readInt());
  164. }
  165. if (c < '0' || c > '9') {
  166. throw new InputMismatchException();
  167. }
  168. m /= 10;
  169. res += (c - '0') * m;
  170. c = read();
  171. }
  172. }
  173. return res * sgn;
  174. }
  175.  
  176. public String next() {
  177. return readString();
  178. }
  179.  
  180. public interface SpaceCharFilter {
  181. public boolean isSpaceChar(int ch);
  182.  
  183. }
  184.  
  185. }
  186. }
  187.  
  188.  
Success #stdin #stdout 0.1s 28272KB
stdin
5
100000000000000 5
100000000000000 1
1 1
3 4
100 1
stdout
4.253387
11.981053
1.000000
1.207384
3.086308