QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#589007 | #9381. 502 Bad Gateway | jjjjjxs | WA | 240ms | 3660kb | C++14 | 975b | 2024-09-25 15:39:03 | 2024-09-25 15:39:03 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define INF 0x3f3f3f3f
#define fr first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N = 1e6 + 10;
ll A(ll c,ll t)
{
return c*(c-1)+2*t;
}
ll B(ll c,ll t)
{
return 2*c;
}
void solve()
{
int t;
cin>>t;
//三分解对勾函数
ll lmid , rmid;
ll lo = 0 , hi = t + 1;//[1,t]
while(lo + 3 < hi)
{
ll lmid = lo + (hi - lo) / 3;
ll rmid = hi - (hi - lo) / 3;
if(A(lmid,t) * B(rmid,t) < A(rmid,t) * B(lmid,t)) hi = rmid;
else lo = lmid;
}
//cout << hi - 1 << endl;
//ll ansc = (A(hi-1,t)*B(hi,t)<A(hi,t)*B(hi-1,t)) ? hi-1 : hi ;
ll above = A(hi-1,t);
ll below = B(hi-1,t);
ll g = __gcd(above,below);
above /= g;
below /= g;
cout << above <<' '<< below << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int T=1; cin>>T;
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 240ms
memory: 3604kb
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 37301136089154041 273134162 1 1 1 1 37301136089154041 273134162 1 1 37301136089154041 273134162 1 1 1 1 1 1 37301136089154041 273134162 1 1 1 1 37301136089154041 273134162 1 1 37301136089154041 273134162 37301136089154041 273134162 1 1 37301136089154041 273134162 1 1 1 1 37301136089154041 273134...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '37301136089154041 273134162'