QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#581611 | #9381. 502 Bad Gateway | ucup-team1769 | WA | 460ms | 3640kb | C++20 | 1.4kb | 2024-09-22 13:35:51 | 2024-09-22 13:35:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
const int mod = 998244353;
struct node // 分数
{
int a, b;
node() {}
node(int a, int b) : a(a), b(b) {}
// 乘法
node operator*(const node &x) const
{
return {a * x.a, b * x.b};
}
// 加法
node operator+(const node &x) const
{
if (b == 0)
return x;
if (x.b == 0)
return *this;
return {a * x.b + x.a * b, b * x.b};
}
// 约分
void reduce()
{
int g = __gcd(a, b);
a /= g;
b /= g;
}
// 输出
friend ostream &operator<<(ostream &out, const node &x)
{
out << x.a << " " << x.b;
return out;
}
} a;
void solve()
{
int n;
cin >> n;
int t = (n * (n + 1) / 2 + (n - 1)) / n;
int len = (n * (n + 1) / 2 + (n - 1)) / n;
// cout << "len = " << len << endl;
// cout << len << " " << n << endl;
node x = node({len * (len + 1) / 2, 1 * n});
node y = node({(n - len) * (n + 3), 2 * n});
// cout << x << endl
// << y << endl;
x.reduce();
y.reduce();
a = x + y;
// cout << t << endl;
a.reduce();
cout << a << endl;
}
signed main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 460ms
memory: 3640kb
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 15253633085958501 -3906250000000000 1 1 1 1 15253633085958501 -3906250000000000 1 1 15253633085958501 -3906250000000000 1 1 1 1 1 1 15253633085958501 -3906250000000000 1 1 1 1 15253633085958501 -3906250000000000 1 1 15253633085958501 -3906250000000000 15253633085958501 -3906250000000000 1 1 1525...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '15253633085958501 -3906250000000000'