QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580829#9381. 502 Bad Gatewayucup-team1769WA 316ms3616kbC++20951b2024-09-22 00:13:552024-09-22 00:13:55

Judging History

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

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

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;
    }
} a;

void solve()
{
    int n;
    cin >> n;
    a = {n * (n + 1) / 2, n};
    a.reduce();

    cout << a.a << " " << a.b << endl;
}

signed main()
{
    cin.tie(0)->ios::sync_with_stdio(false);

    int t = 1;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 316ms
memory: 3616kb

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
1000000001 2
1 1
1 1
1000000001 2
1 1
1000000001 2
1 1
1 1
1 1
1000000001 2
1 1
1 1
1000000001 2
1 1
1000000001 2
1000000001 2
1 1
1000000001 2
1 1
1 1
1000000001 2
1 1
1000000001 2
1000000001 2
1 1
1000000001 2
1000000001 2
1000000001 2
1000000001 2
1000000001 2
1000000001 2
1 1
1 1
1000000001 ...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '1000000001 2'