QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#754646#9381. 502 Bad GatewayYipChip#Compile Error//C++23597b2024-11-16 15:28:532024-11-16 15:28:54

Judging History

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

  • [2024-11-16 15:28:54]
  • 评测
  • [2024-11-16 15:28:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
typedef long long ll;

void solve()
{
    int n;
    cin >> n;
    ll t = sqrt(n << 1);
    ll u1 = (t - 1) * t + 2 * n;
    ll d1 = 2 * t;
    t = t + 1;
    ll u2 = (t - 1) * t + 2 * n;
    ll d2 = 2 * t;
    if ((__int128)u1 * d2 > (__int128)u2 * d1) u1 = u2, d1 = d2;
    cout << u1 / __gcd(u1, d1) << " " << d / __gcd(u1, d1) << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T -- ) solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:17:42: error: ‘d’ was not declared in this scope; did you mean ‘d2’?
   17 |     cout << u1 / __gcd(u1, d1) << " " << d / __gcd(u1, d1) << "\n";
      |                                          ^
      |                                          d2