fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. const ll MOD = 1e9 + 7;
  5. const double PI = 3.14159265358979323846;
  6.  
  7. ll r(ll n) {
  8. ll x = sqrt(n);
  9. while (x * x > n) x--;
  10. while (x * x < n) x++;
  11. return x;
  12. }
  13.  
  14. signed main() {
  15. ios::sync_with_stdio(false);
  16. cin.tie(nullptr);
  17.  
  18. ll t = 1, n, m, k, a, b, c, d, e, f, w, h, x1, x2, y2, l, z, arr[51][51] = {}, q;
  19. string s;
  20. //char x, y;
  21. cin >> t;
  22. while (t--) {
  23. cin >> n;
  24. if (n == 2) {
  25. cout << "0 0 1 1 0 0 0 0 0\n";
  26. continue;
  27. }
  28. ll chk = 0, c = r(n), j;
  29. for (ll i = 0; i < 10; i++, c++) {
  30. for (j = 0; j * 8 <= c * c - n && j <= n; j++) {
  31. if ((c * c - n - j * 8) % 3 == 0 && n - (c * c - n - j * 8) / 3 - j >= 0) {
  32. chk = 1;
  33. break;
  34. }
  35. }
  36. if (chk) {
  37. cout << n - (c * c - n - j * 8) / 3 - j << ' ' << (c * c - n - j * 8) / 3 << ' ' << j << " 0 0 0 0 0 0\n";
  38. break;
  39. }
  40. }
  41. if (!chk) cout << "-1\n";
  42. }
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
23097207633619 1360077 1 0 0 0 0 0 0