QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751765#9622. 有限小数walili#Compile Error//C++203.1kb2024-11-15 20:37:172024-11-15 20:37:19

Judging History

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

  • [2024-11-15 20:37:19]
  • 评测
  • [2024-11-15 20:37:17]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using lll = __int128;
using ll = long long;
#define endl '\n'
const lll inf= 1e17;
const lll mod = 998244353;

const vector<lll> denoms = {
        1, 2, 4, 5, 8,
        10, 16, 20, 25, 32,
        40, 50, 64, 80, 100,
        125, 128, 160, 200, 250,
        256, 320, 400, 500, 512,
        625, 640, 800, 1000, 1024,
        1250, 1280, 1600, 2000, 2048,
        2500, 2560, 3125, 3200, 4000,
        4096, 5000, 5120, 6250, 6400,
        8000, 8192, 10000, 10240, 12500,
        12800, 15625, 16000, 16384, 20000,
        20480, 25000, 25600, 31250, 32000,
        32768, 40000, 40960, 50000, 51200,
        62500, 64000, 65536, 78125, 80000,
        81920, 100000, 102400, 125000, 128000,
        131072, 156250, 160000, 163840, 200000,
        204800, 250000, 256000, 262144, 312500,
        320000, 327680, 390625, 400000, 409600,
        500000, 512000, 524288, 625000, 640000,
        655360, 781250, 800000, 819200, 1000000,
        1024000, 1048576, 1250000, 1280000, 1310720,
        1562500, 1600000, 1638400, 1953125, 2000000,
        2048000, 2097152, 2500000, 2560000, 2621440,
        3125000, 3200000, 3276800, 3906250, 4000000,
        4096000, 4194304, 5000000, 5120000, 5242880,
        6250000, 6400000, 6553600, 7812500, 8000000,
        8192000, 8388608, 9765625, 10000000, 10240000,
        10485760, 12500000, 12800000, 13107200, 15625000,
        16000000, 16384000, 16777216, 19531250, 20000000,
        20480000, 20971520, 25000000, 25600000, 26214400,
        31250000, 32000000, 32768000, 33554432, 39062500,
        40000000, 40960000, 41943040, 48828125, 50000000,
        51200000, 52428800, 62500000, 64000000, 65536000,
        67108864, 78125000, 80000000, 81920000, 83886080,
        97656250, 100000000, 102400000, 104857600, 125000000,
        128000000, 131072000, 134217728, 156250000, 160000000,
        163840000, 167772160, 195312500, 200000000, 204800000,
        209715200, 244140625, 250000000, 256000000, 262144000,
        268435456, 312500000, 320000000, 327680000, 335544320,
        390625000, 400000000, 409600000, 419430400, 488281250,
        500000000, 512000000, 524288000, 536870912, 625000000,
        640000000, 655360000, 671088640, 781250000, 800000000,
        819200000, 838860800, 976562500, 1000000000
};

void oper(lll testcase) {
    int aa = 0, bb = 0;
    lll a = 0, b = 0, e = 0, f = 0, c = 0, d = 0, divisor = 0, best_c = 0, best_d = 0;
    cin >> aa >> bb;
    a = aa;
    b = bb;
    best_c = inf;
    for (lll denom : denoms) {
        f = denom;
        e = (a * f + b - 1) / b;
        c = b * e - a * f;
        d = b * f;
        divisor = gcd(c, d);
        c /= divisor;
        d /= divisor;
        if (d <= 1'000'000'000 && c < best_c) {
            best_c = c;
            best_d = d;
        }
    }
    cout << (ll)best_c << ' ' << (ll)best_d << '\n';
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int ttt = 1;
    cin >> ttt;
    for (lll i = 1; i <= ttt; i++) {
        oper(i);
    }
}

詳細信息

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 = __int128; _Nn = __int128; common_type_t<_Tp1, _Tp2> = __int128]’:
answer.code:68:22:   required from here
/usr/include/c++/13/numeric:166:21: 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:21: note: ‘std::is_integral_v<__int128>’ 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<__int128>’:
/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 = __int128]’
/usr/include/c++/13/numeric:173:24:   required from ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; common_type_t<_Tp1, _Tp2> = __int128]’
answer.code:68:22:   required from here
/usr/include/c++/13/type_traits:1836:62: error: invalid use of incomplete type ‘class std::__make_unsigned_selector<__int128, 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<__int128, false, false>’
 1744 |     class __make_unsigned_selector;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~