QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#592391 | #9381. 502 Bad Gateway | paramecium-4 | WA | 672ms | 3644kb | C++14 | 1.2kb | 2024-09-26 22:13:54 | 2024-09-26 22:13:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
int lmid,rmid;
double check(int k)
{
return (k + 1) / 2.0 + t * 1.0 / k - 1;
}
int main()
{
int T; cin>>T;
while(T--)
{
cin>>t;
int l = 1, r = t;
int id = 1;
double lans,rans,ans = check(1);
//cout<<ans<<endl;
while(l <= r)
{
lmid = l + (r - l + 1) / 3;
rmid = r - (r - l + 1) / 3;
//cout<<lmid<<" "<<rmid<<endl;
lans = check(lmid);
rans = check(rmid);
if(ans > lans) id = lmid, ans = lans;
if(ans > rans) id = rmid, ans = rans;
// cout<<lmid<<' '<<rmid<<' '<<check(lmid)<<' '<<check(rmid)<<endl;
// cout<<lans<<' '<<rans<<' '<<l<<' '<<r<<" "<<id<<endl;
if(lans <= rans) r = rmid - 1;
else l = lmid + 1;
}
for (int i = min(lmid,rmid) - 5;i <= max(lmid,rmid) + 5;i++)
{
if(i < 1 || i > t) continue;
lans = check(i);
if(ans > lans) id = i, ans = lans;
}
//cout<<ans<<" "<<id<<endl;
int x = id * (id - 1) + 2 * t;
int y = 2 * id;
//cout<<id<<' '<<x<<' '<<y<<endl;
//cout<<x<<' '<<y<<endl;
int gg = __gcd(x,y);
x /= gg; y /= gg;
cout<<x<<' '<<y<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 672ms
memory: 3644kb
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 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 1 1 1 1 1 1 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 147522088 -44721 1 1 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 147522088 -44721 1 1 147522088 -44721 147522088 -44721 147522088 -44721 14...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '147522088 -44721'