QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584634 | #9381. 502 Bad Gateway | KULIANLEN | Compile Error | / | / | C++17 | 1.7kb | 2024-09-23 15:57:54 | 2024-09-23 15:57:55 |
Judging History
你现在查看的是最新测评结果
- [2024-09-24 14:55:37]
- hack成功,自动添加数据
- (/hack/886)
- [2024-09-23 15:57:55]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-09-23 15:57:54]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
#define int __int128
#define endl '\n'
using ld = long double;
using pii = pair<int,int>;
pii add(pii a, pii b) {
int x = a.first * b.second + a.second * b.first;
int y = a.second * b.second;
int d = gcd(x, y);
return {x / d, y / d};
}
pii mul(pii a, int k) {
int x = a.first * k;
int y = a.second;
int d = gcd(x, y);
return {x / d, y / d};
}
void solve()
{
long long xx;cin >> xx;
__int128 t = xx;
int delta = 1 + 8 * t;
ld sq = sqrtl(delta);
int x = (1 + sq) / 2;
auto calc = [&](int x) -> pii {
x = min(x, t + 1);
int len = x - 1;
int res = 0;
res += (1 + len) * len / 2;
pii ans = {res, t};
// cout << len << endl;
int d = gcd(ans.first, ans.second);
ans = {ans.first / d, ans.second / d};
if(t - x + 1 > 0)
{
pii tmp = mul(add({t, x - 1}, {x, 2}), t - x + 1);
// cout << tmp.first <<" " << tmp.second << endl;
tmp = {tmp.first, tmp.second * t};
int d = gcd(tmp.first, tmp.second);
tmp.first /= d;tmp.second /= d;
// cout << ans.first <<" " << ans.second <<" " << tmp.first <<" " << tmp.second << endl;
ans = add(ans, tmp);
}
return ans;
};
pii ans = calc(x);
pii ans1 = calc(x + 1);
if(ans1.first * ans.second < ans1.second * ans.first)
{
ans = ans1;
}
cout << (long long)ans.first <<" " << (long long)ans.second << endl;
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(0);
long long T;cin >> T;
while(T--)
solve();
}
详细
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<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; common_type_t<_Mn, _Nn> = __int128]’: answer.code:11:16: 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<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; common_type_t<_Mn, _Nn> = __int128]’ answer.code:11:16: 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; | ^~~~~~~~~~~~~~~~~~~~~~~~