fork(2) download
  1. /* package joney_000 */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.*;
  7.  
  8.  
  9. class Solution
  10.  
  11. {
  12.  
  13. public static void main(String[] args)throws Exception
  14.  
  15. {
  16.  
  17. /* BufferedReader br=new BufferedReader(new FileReader("input.txt"));
  18.   BufferedWriter out=new BufferedWriter(new FileWriter("output.txt"));
  19.   */
  20.  
  21.  
  22.  
  23. int t = Integer.parseInt(br.readLine());
  24. long arr[] = new long[1000001];
  25. for(long i=1;i<=1000000;i++){
  26. arr[(int)i]=(i*(i+1)*(2*i+1))/6;
  27. }
  28. for(int test=0;test<t;test++){
  29.  
  30. long x = Long.parseLong(br.readLine());
  31. int idx = Arrays.binarySearch(arr,1,1000000,x);
  32. if(idx<0){
  33. idx=-idx;idx-=2;
  34. }
  35. long ans = idx ;
  36. out.write(""+ans+"\n");
  37. out.flush();
  38. }
  39.  
  40.  
  41. }//end of public static void main();
  42.  
  43. } //end of class
  44.  
  45.  
Success #stdin #stdout 0.19s 320576KB
stdin
3
1
5
8
stdout
1
2
2