QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#700829#5253. DenormalizationkjhhjkiCompile Error//C++201.3kb2024-11-02 13:25:502024-11-02 13:26:02

Judging History

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

  • [2024-11-02 13:26:02]
  • 评测
  • [2024-11-02 13:25:50]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using f64 = long double;

void solve()
{
    int n;
    std::cin >> n;
    std::vector<f64> a(n + 1), b(n + 1);
    std::vector<int> c(n + 1);
    for(int i = 1; i <= n; ++i) {
        std::cin >> a[i];
    }
    for(int a1 = 1; a1 <= 10000; ++a1) {
        f64 d = a1 / a[1];
        bool f = true;
        for(int i = 1; i <= n; ++i) {
            b[i] = a[i] * d;
            if(fabs(int(b[i] + 5e-7) - b[i]) <= 1e-7) {
                c[i] = int(b[i] + 5e-7);
            } else if(fabs(int(b[i] - 5e-7) - b[i]) <= 1e-7) {
                c[i] = int(b[i] - 5e-7);
            } else {
                f = false;
                break;
            }
        }
        if(f) {
            int g = 0;
            for(int i = 1; i <= n; ++i) {
                if(c[i] == 0) {
                    f = false;
                    break;
                }
                g = std::gcd(g, a[i]);
            }
            if(g != 1) {
                f = false;
            }
        }
        if(f) {
            break;
        }
    }
    for(int i = 1; i <= n; ++i) {
        std::cout << c[i] << '\n';
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    // std::cin >> T;
    while(T --) solve();
    return 0;
}

Details

In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:58,
                 from answer.code:1:
/usr/include/c++/13/numeric: In instantiation of ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = int; _Nn = long double; common_type_t<_Tp1, _Tp2> = long double]’:
answer.code:36:29:   required from here
/usr/include/c++/13/numeric:166:43: error: static assertion failed: std::gcd arguments must be integers
  166 |       static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
      |                                           ^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/numeric:166:43: note: ‘std::is_integral_v<long double>’ evaluates to false
In file included from /usr/include/c++/13/bits/stl_pair.h:60,
                 from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/type_traits: In instantiation of ‘struct std::make_unsigned<long double>’:
/usr/include/c++/13/type_traits:1983:11:   required by substitution of ‘template<class _Tp> using std::make_unsigned_t = typename std::make_unsigned::type [with _Tp = long double]’
/usr/include/c++/13/numeric:173:24:   required from ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = int; _Nn = long double; common_type_t<_Tp1, _Tp2> = long double]’
answer.code:36:29:   required from here
/usr/include/c++/13/type_traits:1836:62: error: invalid use of incomplete type ‘class std::__make_unsigned_selector<long double, false, false>’
 1836 |     { typedef typename __make_unsigned_selector<_Tp>::__type type; };
      |                                                              ^~~~
/usr/include/c++/13/type_traits:1744:11: note: declaration of ‘class std::__make_unsigned_selector<long double, false, false>’
 1744 |     class __make_unsigned_selector;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~