QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584987 | #9381. 502 Bad Gateway | Iron_gainer | WA | 0ms | 3580kb | C++20 | 981b | 2024-09-23 18:14:57 | 2024-09-23 18:14:58 |
Judging History
answer
#include<bits/stdc++.h>
#include<array>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
ll gcd(ll a, ll b)
{
if (b == 0) return a;
else return gcd(b, a % b);
}
void solve()
{
ll num;
cin >> num;
if (num == 1)
{
cout << 1 << " " << 1 << endl;
}
else if (num == 2)
{
cout << 2 << " " << 3 << endl;
}
else if (num == 3)
{
cout << 2 << " "<<1 << endl;
}
else
{
ll c = sqrt(2*num);
ld fz1 = (c - 1) * c + num * 2;
ld fm1 = 2 * c;
c++;
ld fz2 = (c - 1) * c + num * 2;
ld fm2 = 2 * c;
ll fz, fm;
if (fz1 / fm1 < fz2 / fm2)
{
fz = fz1;
fm = fm1;
}
else
{
fz = fz2;
fm = fm2;
}
ll g = gcd(fz, fm);
fz /= g;
fm /= g;
cout << fz << " " << fm << endl;
}
}
void speed()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
speed();
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3580kb
input:
3 1 2 3
output:
1 1 2 3 2 1
result:
wrong answer 2nd lines differ - expected: '3 2', found: '2 3'