QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#580930#9381. 502 Bad GatewayRetr00WA 0ms3676kbC++20625b2024-09-22 01:15:002024-09-22 01:15:02

Judging History

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

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

answer

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

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        ll T, a, b;
        cin >> T;
        a = sqrt(2 * T), b = a + 1;
        double da = a, db = b, aa, ab;
        aa = (da - 1) / 2 + (double)T / da;
        ab = (db - 1) / 2 + (double)T / db;
        if (ab < aa)
            a = b;
        ll g = gcd(a * a - a + 2 * n, 2 * a);

        cout << (a * a - a + 2 * n) / g << " " << 2 * a / g << '\n';
    }

    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3676kb

input:

3
1
2
3

output:

2 1
1 1
1 2

result:

wrong answer 1st lines differ - expected: '1 1', found: '2 1'