import java.util.Scanner; /** * @program: Test * @description: * @author: * @create: 2019-12-31 10:57 **/ public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int i = 0; i < t; i++) { long n = scanner.nextLong(); long[] s = stack(n); System.out.println(s[0]+" "+s[1]+" "+s[2]); } } public static long[] stack(long n) { long[] k=new long[3]; long m = 1; long i=1; k[1]=i; while (n > 0) { if(n>(1+m)*m/2){ n = n - (1 + m) * m / 2; k[0]++; m++; } if(n<(1+m)*m/2){ n-=i; i++; k[1]=i; } } k[0]++; k[1]--; k[2]=k[1]+n; return k; } } |
Double click to view unformatted code.