QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591430#9381. 502 Bad GatewaylamkappaWA 152ms3728kbC++20591b2024-09-26 15:54:392024-09-26 15:54:49

Judging History

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

  • [2024-09-26 15:54:49]
  • 评测
  • 测评结果:WA
  • 用时:152ms
  • 内存:3728kb
  • [2024-09-26 15:54:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64 = long long;

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

    int T = 1;
    cin >> T;
    while(T--){
        int Ti; cin >> Ti;
        double sq2T = sqrt(2*Ti);

        auto f = [&](double x){
            return x/2+Ti/x;
        };

        int t = (f(floor(sq2T)) < f(ceil(sq2T))) ? floor(sq2T) : ceil(sq2T);

        i64 a = t*t + 2*Ti - t;
        i64 b = 2*t;

        i64 gcd = __gcd(a, b);

        cout << a / gcd << ' ' << b / gcd << '\n';
    }

    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 152ms
memory: 3728kb

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
147522088 -44721
1 1
1 1
147522088 -44721
1 1
147522088 -44721
1 1
1 1
1 1
147522088 -44721
1 1
1 1
147522088 -44721
1 1
147522088 -44721
147522088 -44721
1 1
147522088 -44721
1 1
1 1
147522088 -44721
1 1
147522088 -44721
147522088 -44721
1 1
147522088 -44721
147522088 -44721
147522088 -44721
14...

result:

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