QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#584262#9381. 502 Bad GatewaynuoWA 159ms3896kbC++20780b2024-09-23 11:00:152024-09-23 11:00:15

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-23 11:00:15]
  • 评测
  • 测评结果:WA
  • 用时:159ms
  • 内存:3896kb
  • [2024-09-23 11:00:15]
  • 提交

answer

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

#define int long long

int n, T;

int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    while (n--) {
        cin >> T;
        int num1 = floor(sqrt(2 * T)), num2 = ceil(sqrt(2 * T));
        int x1 = 2 * T + num1 * (num1 - 1), y1 = 2 * num1;
        int x2 = 2 * T + num2 * (num2 - 1), y2 = 2 * num2;
        int GCD;
        if (x1 * y2 > x2 * y1) {
            GCD = gcd(x1, y1);
            x1 /= GCD, y1 /= GCD;
            printf("%lld %lld\n", x1, y1);
        } else {
            GCD = gcd(x2, y2);
            x2 /= GCD, y2 /= GCD;
            printf("%lld %lld\n", x2, y2);
        }
    }
    return 0;
}

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 159ms
memory: 3876kb

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'