QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#581826 | #9381. 502 Bad Gateway | KULIANLEN# | WA | 307ms | 3648kb | C++17 | 1.4kb | 2024-09-22 14:17:26 | 2024-09-22 14:17:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#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.first * b.second;
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()
{
int t;cin >> t;
int delta = 1 + 8 * t;
ld sq = sqrtl(delta);
int x = ceill((1 + sq) / 2);
int res = 0;
x = min(x, t + 1);
int len = x - 1;
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);
}
cout << ans.first <<" " << ans.second << endl;
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(0);
int T;cin >> T;
while(T--)
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 307ms
memory: 3628kb
input:
1000000 1 1000000000 1 1 1000000000 1 1000000000 1 1 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1000000000 1 1000000000 1000000000 1000000000 1000000000 1 1 1 10000000...
output:
1 1 1000006281 500000000 1 1 1 1 1000006281 500000000 1 1 1000006281 500000000 1 1 1 1 1 1 1000006281 500000000 1 1 1 1 1000006281 500000000 1 1 1000006281 500000000 1000006281 500000000 1 1 1000006281 500000000 1 1 1 1 1000006281 500000000 1 1 1000006281 500000000 1000006281 500000000 1 1 100000628...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '1000006281 500000000'