QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#586698#9381. 502 Bad Gatewayucup-team1769WA 171ms3592kbC++20935b2024-09-24 15:06:062024-09-24 15:06:06

Judging History

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

  • [2024-09-24 15:06:06]
  • 评测
  • 测评结果:WA
  • 用时:171ms
  • 内存:3592kb
  • [2024-09-24 15:06:06]
  • 提交

answer

#include <bits/stdc++.h>

using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;

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

    for (int i = 0; i < n; i++) {
        int t;
        std::cin >> t;

        int a = floor(std::sqrt(2 * t));
        int b = ceil(std::sqrt(2 * t));

        int a_ = (a - 1) * a + 2 * t;
        int b_ = (b - 1) * b + 2 * t;
        int _a = 2 * a;
        int _b = 2 * b;
        int ga = std::gcd(a_, _a);
        int gb = std::gcd(b_, _b);
        a_ /= ga, _a /= ga;
        b_ /= gb, _b /= gb;
        if (a_ * _b > b_ * _a) {
            std::cout << a_ << " " << _a << "\n";
        } else {
            std::cout << b_ << " " << _b << "\n";
        }
    }
}

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

    int t;
    //std::cin >> t;
    t = 1;

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

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 171ms
memory: 3588kb

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
-147477367 44722
1 1
1 1
-147477367 44722
1 1
-147477367 44722
1 1
1 1
1 1
-147477367 44722
1 1
1 1
-147477367 44722
1 1
-147477367 44722
-147477367 44722
1 1
-147477367 44722
1 1
1 1
-147477367 44722
1 1
-147477367 44722
-147477367 44722
1 1
-147477367 44722
-147477367 44722
-147477367 44722
-1...

result:

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