int main() { int count = 0; for ( aint t=0; t>=0; ++t ) { aint ft = tri(t); aint p = 0; pair pr = solve_quad(3, -1, -2 * ft); if ( pr.a>=0 && pent(pr.a) == ft ) p = pr.a; if ( pr.b>=0 && pent(pr.b) == ft ) p = pr.b; if ( p == 0 ) continue; aint h = 0; pair hr = solve_quad(2, -1, -ft); if ( hr.a>=0 && hex(hr.a) == ft ) h = hr.a; if ( hr.b>=0 && hex(hr.b) == ft ) h = hr.b; if ( h == 0 ) continue; printf("T%d = P%d = H%d = %d\n", t, p, h, ft); if ( ++count >= 3 ) break; } }
int main() { scanf("%d", &tc); while (tc--) { scanf("%d", &n); num = 1; r = solve_quad(n); base = (r * (r - 1)) / 2 + 1; while (base++ != n) { num++; } if (r & 1) printf("TERM %d IS %d/%d\n", n, (r + 1) - num, num); else printf("TERM %d IS %d/%d\n", n, num, (r + 1) - num); } return 0; }