QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#494675#5003. Etched Emerald OrbsInk_baiCompile Error//C++141.1kb2024-07-27 16:31:542024-07-27 16:31:54

Judging History

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

  • [2024-07-27 16:31:54]
  • 评测
  • [2024-07-27 16:31:54]
  • 提交

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 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;
}

詳細信息

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: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)
      |   ^~~~