QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#579972 | #9381. 502 Bad Gateway | xjt05 | WA | 435ms | 3688kb | C++23 | 857b | 2024-09-21 19:30:58 | 2024-09-21 19:30:58 |
Judging History
answer
#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
#include<bitset>
#include<math.h>
#include<string>
#include<string.h>
//#include<>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
ll gcd(ll a, ll b) {
if (b == 0) return a;
else return gcd(b, a % b);
}
void fio()
{
ios::sync_with_stdio();
cin.tie(0);
cout.tie(0);
}
int main()
{
fio();
ll t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
ll k;
ll l = 1, r = n;
while (l < r)
{
ll mid = (l + r) >> 1;
if ((mid * mid - mid) / 2 < n)
{
l = mid + 1;
}
else if ((mid * mid + mid) / 2 >= n)
{
r = mid;
}
}
k = r;
//cout << k << endl;
ll x = k * (k + 1) + 2 * (n - k);
ll y = k * 2;
ll u = gcd(x, y);
cout << x / u << " " << y / u << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3688kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 435ms
memory: 3596kb
input:
1000000 1 1000000000 1 1 1000000000 1 1000000000 1 1 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1000000000 1 1000000000 1000000000 1000000000 1000000000 1 1 1 10000000...
output:
1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 1 1 1 1 1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 2000006281 44722 1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 2000006281 44722 1 1 2000006281 44722 2000006281 44722 2000006281 44722 20...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '2000006281 44722'