QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#516900#9168. Square Locatorucup-team1198#Compile Error//C++142.0kb2024-08-12 23:30:012024-08-12 23:30:02

Judging History

你现在查看的是最新测评结果

  • [2024-08-12 23:30:02]
  • 评测
  • [2024-08-12 23:30:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int __int128

int perfect_sqrt(int x) {
    int res = sqrt(x);
    while (res * res > x) --res;
    while ((res + 1) * (res + 1) <= x) ++res;
    if (res * res == x) return res;
    return -1;
}

const int INF = 2e18;

int norm(array<int, 2> elem) {
    if (elem[0] > sqrt(INF) || elem[1] > sqrt(INF)) return -1;
    return elem[0] * elem[0] + elem[1] * elem[1];
}

void print(int x) {
    cout << (int64_t)x << " ";
}

void solve_() {
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    for (int _ = 0; _ < 2; ++_, swap(b, d)) {
        if (d - a != c - b) continue;
        int y = perfect_sqrt(a);
        if (y == -1) continue;
        int t = 2 * b - a - c;
        if (t % (2 * y) != 0) continue;
        t /= (2 * y);
        if (t > sqrt(INF) + 100) continue;
        int A = 2, B = 2 * (t + y), C = t * t + b - c;
        int D = B * B - 4 * A * C;
        D = perfect_sqrt(D);
        if (D == -1) continue;
        for (int s = -1; s <= 1; s += 2) {
            int dx = -B + s * D;
            if (dx % 4 != 0) continue;
            dx /= 4;
            int dy = dx + t;
            array<int, 2> pa = {0, y};
            array<int, 2> pb = {dx, y + dy};
            array<int, 2> pc = {dx - dy, y + dx + dy};
            array<int, 2> pd = {-dy, y + dx};
            if (norm(pa) != a) continue;
            if (norm(pb) != b) continue;
            if (norm(pc) != c) continue;
            if (norm(pd) != d) continue;
            if (_) swap(pb, pd);
            print(y);
            print(pb[0]); print(pb[1]);
            print(pc[0]); print(pc[1]);
            print(pd[0]); print(pd[1]);
            cout << "\n";
            return;
        }
    }
}

/// #define MULTITEST

main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int tst = 1;
#ifdef MULTITEST
    cin >> tst;
#endif // MULTITEST
    while (tst--) {
        solve_();
    }
    return 0;
}

Details

answer.code: In function ‘__int128 perfect_sqrt(__int128)’:
answer.code:7:19: error: call of overloaded ‘sqrt(__int128&)’ is ambiguous
    7 |     int res = sqrt(x);
      |               ~~~~^~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/c++config.h:679,
                 from /usr/include/c++/13/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:33,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:143:1: note: candidate: ‘double sqrt(double)’
  143 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:114:
/usr/include/c++/13/cmath:442:3: note: candidate: ‘constexpr long double std::sqrt(long double)’
  442 |   sqrt(long double __x)
      |   ^~~~
/usr/include/c++/13/cmath:438:3: note: candidate: ‘constexpr float std::sqrt(float)’
  438 |   sqrt(float __x)
      |   ^~~~
answer.code: In function ‘__int128 norm(std::array<__int128, 2>)’:
answer.code:17:23: error: call of overloaded ‘sqrt(const __int128&)’ is ambiguous
   17 |     if (elem[0] > sqrt(INF) || elem[1] > sqrt(INF)) return -1;
      |                   ~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:143:1: note: candidate: ‘double sqrt(double)’
  143 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
/usr/include/c++/13/cmath:442:3: note: candidate: ‘constexpr long double std::sqrt(long double)’
  442 |   sqrt(long double __x)
      |   ^~~~
/usr/include/c++/13/cmath:438:3: note: candidate: ‘constexpr float std::sqrt(float)’
  438 |   sqrt(float __x)
      |   ^~~~
answer.code:17:46: error: call of overloaded ‘sqrt(const __int128&)’ is ambiguous
   17 |     if (elem[0] > sqrt(INF) || elem[1] > sqrt(INF)) return -1;
      |                                          ~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:143:1: note: candidate: ‘double sqrt(double)’
  143 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
/usr/include/c++/13/cmath:442:3: note: candidate: ‘constexpr long double std::sqrt(long double)’
  442 |   sqrt(long double __x)
      |   ^~~~
/usr/include/c++/13/cmath:438:3: note: candidate: ‘constexpr float std::sqrt(float)’
  438 |   sqrt(float __x)
      |   ^~~~
answer.code: In function ‘void solve_()’:
answer.code:35:21: error: call of overloaded ‘sqrt(const __int128&)’ is ambiguous
   35 |         if (t > sqrt(INF) + 100) continue;
      |                 ~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:143:1: note: candidate: ‘double sqrt(double)’
  143 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
/usr/include/c++/13/cmath:442:3: note: candidate: ‘constexpr long double std::sqrt(long double)’
  442 |   sqrt(long double __x)
      |   ^~~~
/usr/include/c++/13/cmath:438:3: note: candidate: ‘constexpr float std::sqrt(float)’
  438 |   sqrt(float __x)
      |   ^~~~
answer.code: At global scope:
answer.code:66:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   66 | main() {
      | ^~~~