QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581406 | #9381. 502 Bad Gateway | Young_Cloud | RE | 0ms | 0kb | C++17 | 1011b | 2024-09-22 12:34:57 | 2024-09-22 12:34:58 |
Judging History
answer
#include<bits/stdc++.h>
#define IOS std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0)
using i64 = long long;
using i128 = __int128_t;
constexpr i64 Mod = 998244353, Inf = 1e18;
constexpr int N = 1e5, M = 1e5;
i64 T;
void print(i64 c) {
i64 a = (c - 1) * c + T * 2;
i64 b = 2 * c;
i64 g = std::__gcd(a, b);
std::cout << a / g << " " << b / g << '\n';
}
void solve()
{
std::cin >> T;
i64 l = 0, r = T;
while (l <= r) {
i64 m = l + r >> 1;
if (m * m < 2 * T) {
l = m + 1;
}
else {
r = m - 1;
}
}
if (l * l == 2 * T) {
print(l);
}
else if (1.0 * l / 2.0 + 1.0 * T / l < 1.0 * r / 2.0 + 1.0 * T / r) {
print(l);
}
else {
print(r);
}
return;
}
int main()
{
IOS;
int t = 1;
std::cin >> t;
while (t--)
{
solve();
}
system("pause");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
3 1 2 3