QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#585666 | #9381. 502 Bad Gateway | KULIANLEN | Compile Error | / | / | C++20 | 1.8kb | 2024-09-23 21:42:45 | 2024-09-23 21:42:46 |
Judging History
你现在查看的是最新测评结果
- [2024-09-24 14:55:37]
- hack成功,自动添加数据
- (/hack/886)
- [2024-09-23 21:42:46]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-09-23 21:42:45]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
using ld = long double;
struct pii {
int first, second;
};
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 = ceill((1 + sq) / 2);
// cout << (long long)(x * x - x - 2 * t) << endl;
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();
}
Details
answer.code: In lambda function: answer.code:36:16: error: no matching function for call to ‘min(long long int&, __int128)’ 36 | x = min(x, t + 1); | ~~~^~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: answer.code:36:16: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__int128’) 36 | x = min(x, t + 1); | ~~~^~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: template argument deduction/substitution failed: answer.code:36:16: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__int128’) 36 | x = min(x, t + 1); | ~~~^~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’ 5775 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5775:5: note: template argument deduction/substitution failed: answer.code:36:16: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 36 | x = min(x, t + 1); | ~~~^~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’ 5785 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: template argument deduction/substitution failed: answer.code:36:16: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 36 | x = min(x, t + 1); | ~~~^~~~~~~~~~ answer.code:41:25: warning: narrowing conversion of ‘t’ from ‘__int128’ to ‘long long int’ [-Wnarrowing] 41 | pii ans = {res, t}; | ^ answer.code:47:28: warning: narrowing conversion of ‘t’ from ‘__int128’ to ‘long long int’ [-Wnarrowing] 47 | pii tmp = mul(add({t, x - 1}, {x, 2}), t - x + 1); | ^ answer.code:49:38: warning: narrowing conversion of ‘(((__int128)tmp.pii::second) * t)’ from ‘__int128’ to ‘long long int’ [-Wnarrowing] 49 | tmp = {tmp.first, tmp.second * t}; | ~~~~~~~~~~~^~~