QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#494717#5003. Etched Emerald OrbsInk_baiCompile Error//C++231.1kb2024-07-27 16:42:002024-07-27 16:42:01

Judging History

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

  • [2024-07-27 16:42:01]
  • 评测
  • [2024-07-27 16:42:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define uint unsigned long long
#define int long long
#define endl '\n'
const int N = 1e4 + 5;
typedef pair<int, int> PII;
#define MAX LONG_LONG_MAX

int a[N], b[N], c[N];
std::string to_string_(__int128_t value)
{
    if (value == 0)
        return "0";

    std::string result;
    bool is_negative = (value < 0);
    if (is_negative)
        value = -value;

    while (value > 0)
    {
        result.push_back('0' + (value % 10));
        value /= 10;
    }

    if (is_negative)
        result.push_back('-');

    std::reverse(result.begin(), result.end());
    return result;
}

void solve()
{
    int k;
    cin >> k;
    __int128_t res = k + 1;
    double q;
    for (;; res++)
    {
        __int128_t x = res * (res - k);
        q = sqrt(x);
        if (q - (int)q == 0)
        {
            break;
        }
    }

    string a = to_string_(res - q);
    string b = to_string_(res + q);

    cout << a << ' ' << b << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:43:17: error: call of overloaded ‘sqrt(__int128&)’ is ambiguous
   43 |         q = 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:1037:3: note: candidate: ‘constexpr __gnu_cxx::__bfloat16_t std::sqrt(__gnu_cxx::__bfloat16_t)’
 1037 |   sqrt(__gnu_cxx::__bfloat16_t __x)
      |   ^~~~
/usr/include/c++/13/cmath:943:3: note: candidate: ‘constexpr _Float128 std::sqrt(_Float128)’
  943 |   sqrt(_Float128 __x)
      |   ^~~~
/usr/include/c++/13/cmath:761:3: note: candidate: ‘constexpr _Float64 std::sqrt(_Float64)’
  761 |   sqrt(_Float64 __x)
      |   ^~~~
/usr/include/c++/13/cmath:667:3: note: candidate: ‘constexpr _Float32 std::sqrt(_Float32)’
  667 |   sqrt(_Float32 __x)
      |   ^~~~
/usr/include/c++/13/cmath:573:3: note: candidate: ‘constexpr _Float16 std::sqrt(_Float16)’
  573 |   sqrt(_Float16 __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)
      |   ^~~~