QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585254 | #9381. 502 Bad Gateway | Coffeecat996 | WA | 214ms | 3640kb | C++14 | 1.8kb | 2024-09-23 19:57:44 | 2024-09-23 19:57:45 |
Judging History
answer
// !红色注释
// ?蓝色注释
// //灰色删除线注释
// todo 橘红色注释
//*浅绿色注释
/**
* @file :b.cpp
* @author :Coffeecat996
* @version :V1.0.0
* @date :2024-09-23
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve()
{
int t;
cin >> t;
int c1 = (int)(sqrt(t * 2));
int c2= (int)(sqrt(t * 2))+((pow((int)(sqrt(t * 2)),2)==t*2)?0:1);
// cout<< c1 << " " << c2 << "???"<<endl;
// cout << "t:" << t << " c:" << c << endl;
double ans1, ans2;
// cout<< c1 << " " << c2 << endl;
// return;
ans1 = (c1 - 1) / 2 + t / c1;
ans2 = (c2 - 1) / 2 + t / c2;
// cout<< ans1 << " " << ans2 <<"??" <<endl;
int fz, fm;
if(ans1<ans2)
{
pair<int, int> a = {c1 - 1, 2};
pair<int, int> b = {t, c1};
int gcd= __gcd(a.first, a.second);
a.first /= gcd;
a.second /= gcd;
gcd = __gcd(b.first, b.second);
b.first /= gcd;
b.second /= gcd;
fz = a.first * b.second + a.second * b.first;
fm = a.second * b.second;
gcd= __gcd(fz, fm);
cout << fz / gcd << " " << fm / gcd << endl;
}
else
{
pair<int, int> a = {c2 - 1, 2};
pair<int, int> b = {t, c2};
int gcd = __gcd(a.first, a.second);
a.first /= gcd;
a.second /= gcd;
gcd = __gcd(b.first, b.second);
b.first /= gcd;
b.second /= gcd;
fz = a.first * b.second + a.second * b.first;
fm = a.second * b.second;
gcd = __gcd(fz, fm);
cout << fz / gcd << " " << fm / gcd << endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 214ms
memory: 3640kb
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'