QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#581932#9381. 502 Bad GatewayMuQYYWA 547ms3604kbC++17644b2024-09-22 14:39:302024-09-22 14:39:32

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve()
{
    int n;
    cin >> n;
    int c1 = sqrt(2 * n); // lower
    int c2 = c1 + 1; // higher
    long long a1 = c1 * c1 - c1 + 2 * n;
    long long a2 = c2 * c2 - c2 + 2 * n;
    long long b1 = 2 * c1;
    long long b2 = 2 * c2; 
    if(a1 * b2 < a2 * b1)
    {
        cout << a1 / __gcd(a1, b1) << ' ' << b1 / __gcd(a1, b1) << endl;
    }
    else{
        cout << a2 / __gcd(a2, b2) << ' ' << b2 / __gcd(a2, b2) << endl;
    }
}

int main()
{
    int t;
    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: 3444kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 547ms
memory: 3604kb

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'