QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580729#9381. 502 Bad GatewaytieguodundaeWA 0ms3628kbC++141.4kb2024-09-21 23:22:112024-09-21 23:22:19

Judging History

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

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

answer

#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", print_args(__VA_ARGS__)
template <class... T>
void print_args(T... args) { ((cerr << args << ' '), ...) << '\n'; }
using u32 = unsigned;
using u64 = unsigned long long;
using i64 = long long;
using i128 = __int128_t;
const int mod = 998244353;
void solve() {
    int n;
    cin >> n;
    int l = 1, r = n;
    int t;
    while (l <= r) {
        int mid = (l + r + 1) / 2;
        if ((mid - 1) * mid >= 2 * n) {
            t = mid, r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    t -= 1;
    int x = 0, y = 1;
    if (t > 0 && t <= n) {
        x = t * (t + 1) / 2;
    }
    if (t + 1 <= n) {
        int fz = t * t + t + 2 * n;
        int fm = 2 * t;
        int g = __gcd(fz, fm);
        fz /= g;
        fm /= g;
        fz *= (n - t);
        x = x * fm + y * fz;
        y = y * fm;
        g = __gcd(fz, fm);
        x /= g;
        y /= g;
    }
    y = y * n;
    int g = __gcd(x, y);
    x /= g;
    y /= g;
    cout << x << ' ' << y << '\n';
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
3

output:

0 1
0 1
2 1

result:

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