QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580729 | #9381. 502 Bad Gateway | tieguodundae | WA | 0ms | 3628kb | C++14 | 1.4kb | 2024-09-21 23:22:11 | 2024-09-21 23:22:19 |
Judging History
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'