QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#584497#9381. 502 Bad GatewaymoosyWA 187ms3704kbC++20657b2024-09-23 14:52:382024-09-23 14:52:39

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-23 14:52:39]
  • 评测
  • 测评结果:WA
  • 用时:187ms
  • 内存:3704kb
  • [2024-09-23 14:52:38]
  • 提交

answer

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

void Solve() {
    ll n; cin >> n;
    ll x = ceil(sqrt(2 * n));
    ll y = ceil(sqrt(2 * n)) == sqrt(2 * n) ? x : x - 1;
    ll a1 = x * x + 2 * n - x; ll b1 = 2 * x;
    ll a2 = y * y + 2 * n - y; ll b2 = 2 * y;
    if(a1 * b2 >= a2 * b1) {
        cout << a1 / __gcd(a1, b1) << " " << b1 / __gcd(a1, b1) << "\n";
    } else {
        cout << a2 / __gcd(a2, b2) << " " << b2 / __gcd(a2, b2) << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll t; cin >> t;
    while(t -- ) {
        Solve();
    } 
    return 0;
}

詳細信息

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 187ms
memory: 3704kb

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
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
1 1
1 1
1 1
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
2000006281 44722
1 1
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
2000006281 44722
1 1
2000006281 44722
2000006281 44722
2000006281 44722
20...

result:

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