QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582015#9381. 502 Bad GatewayWood#WA 190ms3552kbC++231.1kb2024-09-22 14:59:372024-09-22 14:59:37

Judging History

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

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

answer

#include <bits/stdc++.h>

using i64 = long long;

using i128 = __int128;
std::istream &operator>>(std::istream &is, i128 &n) {
    n = 0;
    std::string s;
    is >> s;

    for (auto c : s) {
        n = 10 * n + c - '0';
    }
    return is;
}
std::ostream &operator<<(std::ostream &os, i128 n) {
    if (n == 0) {
        return os << 0;
    }
    std::string s;
    while (n > 0) {
        s += '0' + n % 10;
        n /= 10;
    }
    std::reverse(s.begin(), s.end());
    return os << s;
}

i128 gcd(i128 a, i128 b) {
    return b ? gcd(b, a % b) : a;
}

void solve() {
    int n;
    std::cin >> n;

    if (n == 2) {
        std::cout << "3 2\n";
        return;
    }

    i128 x = (n + 1) / 2, y = n - x;
    i128 num = x * x * (x + 1) + y * (x * (x + 1) + 2 * n);
    i128 den = x * n * 2;

    i128 g = gcd(num, den);
    num /= g;
    den /= g;

    std::cout << num << " " << den << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int T;
    std::cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 190ms
memory: 3552kb

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

result:

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