QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581611#9381. 502 Bad Gatewayucup-team1769WA 460ms3640kbC++201.4kb2024-09-22 13:35:512024-09-22 13:35:51

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 13:35:51]
  • 评测
  • 测评结果:WA
  • 用时:460ms
  • 内存:3640kb
  • [2024-09-22 13:35:51]
  • 提交

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'