Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- class Codechef
- {
- static FastIO f;
- static HashSet<Long> p;
- public static void main(String args[]) throws java.lang.Exception
- {
- int i, t;
- preprocess();
- for(i = 0; i < 1; i++)
- {
- f = new FastIO();
- t = f.ni();
- while(t-->0)
- solve();
- }
- }
- public static void preprocess() throws IOException
- {
- f = new FastIO();
- p = new HashSet<>();
- long i, j;
- for(i = 1; i <= 10000; i++)
- p.add(i*i*i);
- }
- public static void solve() throws IOException
- {
- long n = f.nl(), x = 0, a, i = 0;
- long j = 0;
- for(a = 1; a*a*a < n; a++)
- {
- x = n - a*a*a;
- for(i = a; i*i*i < x; i++)
- {
- // if(Math.cbrt(x - i*i*i)%1.0 == 0.0)
- if(p.contains(x - i*i*i))
- {
- j = (long)Math.cbrt(x - i*i*i);
- break;
- }
- }
- if(i*i*i < x)
- break;
- }
- f.out((i*i*i < x) ? (a*a*a + " " + i*i*i + " " + j*j*j + "\n") : "-1\n");
- f.flush();
- // System.err.println("Completed");
- }
- public static class FastIO
- {
- BufferedReader br;
- BufferedWriter bw, be;
- StringTokenizer st;
- public FastIO()
- {
- br = new BufferedReader(new InputStreamReader(System.in));
- bw = new BufferedWriter(new OutputStreamWriter(System.out));
- be = new BufferedWriter(new OutputStreamWriter(System.err));
- st = new StringTokenizer("");
- }
- private void read() throws IOException
- {
- st = new StringTokenizer(br.readLine());
- }
- public String ns() throws IOException
- {
- while(!st.hasMoreTokens())
- read();
- return st.nextToken();
- }
- public int ni() throws IOException
- {
- return Integer.parseInt(ns());
- }
- public long nl() throws IOException
- {
- return Long.parseLong(ns());
- }
- public float nf() throws IOException
- {
- return Float.parseFloat(ns());
- }
- public double nd() throws IOException
- {
- return Double.parseDouble(ns());
- }
- public char nc() throws IOException
- {
- return ns().charAt(0);
- }
- public int[] nia(int n) throws IOException
- {
- int[] a = new int[n];
- for(int i = 0; i < n; i++)
- a[i] = ni();
- return a;
- }
- public long[] nla(int n) throws IOException
- {
- long[] a = new long[n];
- for(int i = 0; i < n; i++)
- a[i] = nl();
- return a;
- }
- public char[] nca() throws IOException
- {
- return ns().toCharArray();
- }
- public void out(String s) throws IOException
- {
- bw.write(s);
- }
- public void flush() throws IOException
- {
- bw.flush();
- be.flush();
- }
- public void err(String s) throws IOException
- {
- be.write(s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement