Advertisement
Guest User

Untitled

a guest
May 2nd, 2021
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.63 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. class Codechef
  5. {
  6.  
  7.     static FastIO f;
  8.     static HashSet<Long> p;
  9.  
  10.     public static void main(String args[]) throws java.lang.Exception
  11.     {
  12.         int i, t;
  13.  
  14.         preprocess();
  15.  
  16.         for(i = 0; i < 1; i++)
  17.         {
  18.             f = new FastIO();
  19.  
  20.             t = f.ni();
  21.  
  22.             while(t-->0)
  23.                 solve();
  24.         }
  25.     }
  26.  
  27.     public static void preprocess() throws IOException
  28.     {
  29.         f = new FastIO();
  30.         p = new HashSet<>();
  31.         long i, j;
  32.  
  33.         for(i = 1; i <= 10000; i++)
  34.             p.add(i*i*i);
  35.     }
  36.  
  37.     public static void solve() throws IOException
  38.     {
  39.         long n = f.nl(), x = 0, a, i = 0;
  40.         long j = 0;
  41.  
  42.         for(a = 1; a*a*a < n; a++)
  43.         {
  44.             x = n - a*a*a;
  45.  
  46.             for(i = a; i*i*i < x; i++)
  47.             {
  48.                 // if(Math.cbrt(x - i*i*i)%1.0 == 0.0)
  49.                 if(p.contains(x - i*i*i))
  50.                 {
  51.                     j = (long)Math.cbrt(x - i*i*i);
  52.                     break;
  53.                 }
  54.             }
  55.  
  56.             if(i*i*i < x)
  57.                 break;
  58.         }
  59.  
  60.         f.out((i*i*i < x) ? (a*a*a + " " + i*i*i + " " + j*j*j + "\n") : "-1\n");
  61.  
  62.         f.flush();
  63. //      System.err.println("Completed");
  64.     }
  65.  
  66.     public static class FastIO
  67.     {
  68.         BufferedReader br;
  69.         BufferedWriter bw, be;
  70.         StringTokenizer st;
  71.  
  72.         public FastIO()
  73.         {
  74.             br = new BufferedReader(new InputStreamReader(System.in));
  75.             bw = new BufferedWriter(new OutputStreamWriter(System.out));
  76.             be = new BufferedWriter(new OutputStreamWriter(System.err));
  77.             st = new StringTokenizer("");
  78.         }
  79.  
  80.         private void read() throws IOException
  81.         {
  82.             st = new StringTokenizer(br.readLine());
  83.         }
  84.  
  85.         public String ns() throws IOException
  86.         {
  87.             while(!st.hasMoreTokens())
  88.                 read();
  89.             return st.nextToken();
  90.         }
  91.  
  92.         public int ni() throws IOException
  93.         {
  94.             return Integer.parseInt(ns());
  95.         }
  96.  
  97.         public long nl() throws IOException
  98.         {
  99.             return Long.parseLong(ns());
  100.         }
  101.  
  102.         public float nf() throws IOException
  103.         {
  104.             return Float.parseFloat(ns());
  105.         }
  106.  
  107.         public double nd() throws IOException
  108.         {
  109.             return Double.parseDouble(ns());
  110.         }
  111.  
  112.         public char nc() throws IOException
  113.         {
  114.             return ns().charAt(0);
  115.         }
  116.  
  117.         public int[] nia(int n) throws IOException
  118.         {
  119.             int[] a = new int[n];
  120.             for(int i = 0; i < n; i++)
  121.                 a[i] = ni();
  122.  
  123.             return a;
  124.         }
  125.  
  126.         public long[] nla(int n) throws IOException
  127.         {
  128.             long[] a = new long[n];
  129.             for(int i = 0; i < n; i++)
  130.                 a[i] = nl();
  131.  
  132.             return a;
  133.         }
  134.  
  135.         public char[] nca() throws IOException
  136.         {
  137.             return ns().toCharArray();
  138.         }
  139.  
  140.         public void out(String s) throws IOException
  141.         {
  142.             bw.write(s);
  143.         }
  144.  
  145.         public void flush() throws IOException
  146.         {
  147.             bw.flush();
  148.             be.flush();
  149.         }
  150.  
  151.         public void err(String s) throws IOException
  152.         {
  153.             be.write(s);
  154.         }
  155.     }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement