/* -*- coding: utf-8 -*- * * 1626.cc: No.1626 三角形の構築 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ /* typedef */ typedef long long ll; struct Trpl { int a, b, c; Trpl() {} Trpl(int _a, int _b, int _c): a(_a), b(_b), c(_c) {} void print() { printf("%d %d %d\n", a, b, c); } }; typedef vector vt; /* global variables */ /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { ll s, t; scanf("%lld%lld", &s, &t); ll ss = s * s, ht = t / 2; if ((t & 1) || ss % ht != 0) { puts("0"); continue; } ll xyz = ss / ht; vt ans; for (int x = 1; x < ht && (ll)x * x * x <= xyz; x++) if (xyz % x == 0) { ll yz = xyz / x; for (int y = x; y < ht && (ll)y * y <= yz; y++) if (yz % y == 0) { ll z = yz / y; if (z < ht) { int a = ht - z, b = ht - y, c = ht - x; if ((ll)a + b + c == t) ans.push_back(Trpl(a, b, c)); } } } printf("%lu\n", ans.size()); for (auto p: ans) p.print(); } return 0; }