#include <stdio.h> #include <math.h> #include <string.h> int main(){ int t; scanf("%d",&t); while(t--){ long long x; scanf("%lld",&x); long long heap_no=1,row=1,nextheap=1; while(x>nextheap){ x-=nextheap; heap_no++; nextheap+=heap_no; } while(x>row){ x-=row; row++; } printf("%lld %lld %lld\n",heap_no,row,x); } return 0; } |
Double click to view unformatted code.