QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190595#5253. DenormalizationtimreizinCompile Error//C++201.4kb2023-09-29 07:10:302023-09-29 07:10:31

Judging History

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

  • [2023-09-29 07:10:31]
  • 评测
  • [2023-09-29 07:10:30]
  • 提交

answer

#include <vector>
#include <queue>
#include <list>
#include <iostream>
#include <array>
#include <string>
#include <numeric>

using namespace std;

using ll = long long;
using ld = long double;

const ll MULT = 1000000000000;

ll round(ll x)
{
    ll md = x % MULT;
    if (md < MULT / 2)
        return x / MULT;
    return (x + MULT - 1) / MULT;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> a(n);
    for (ll &i : x)
    {
        string s;
        cin >> s;
        s.erase(s.begin() + 1);
        i = stoll(s);
    }
    auto check = [&x, &a, &n](ll d)
    {
        a[0] = round(x.front() * d);
        ll gcded = a[0];
        for (int i = 1; i < n; ++i)
        {
            a[i] = round(x[i] * d);
            gcded = gcd(a[i], gcded);
        }
        if (gcded != 1)
            return false;
        ll sum = 0;
        for (ll i : a)
            sum += i * i;
        ld nd = sqrtl(sum);
        for (int i = 0; i < n; ++i)
        {
            ll nx = roundl((a[i] / nd) * MULT);
            if (abs(x[i] - nx) > 1000000)
                return false;
        }
        return true;
    };
    for (ll a1 = 0; a1 <= 10000; ++a1)
    {
        if (check((a1 * MULT) / x.front()))
            break;
        if (check((a1 * MULT + x.front() - 1) / x.front()))
            break;
    }
    for (ll i : a)
        cout << i << '\n';
    return 0;
}

詳細信息

answer.code: In lambda function:
answer.code:51:17: error: ‘sqrtl’ was not declared in this scope; did you mean ‘strtol’?
   51 |         ld nd = sqrtl(sum);
      |                 ^~~~~
      |                 strtol
answer.code:54:21: error: ‘roundl’ was not declared in this scope; did you mean ‘round’?
   54 |             ll nx = roundl((a[i] / nd) * MULT);
      |                     ^~~~~~
      |                     round