QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#582186 | #9381. 502 Bad Gateway | jxjxjx | WA | 851ms | 3704kb | C++20 | 1.4kb | 2024-09-22 15:35:38 | 2024-09-22 15:35:39 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define int long long
#define sqrt sqrtl
#define all(x) (x).begin(),(x).end()
#define mem(x,y,l,r) for(int _=l;_<=r;_++) x[_]=y;
#define jxjxjx
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...) (void)42
#endif
using namespace std;
typedef pair<long ,long > pii;
typedef pair<char,int > pci;
const int N = 2e6+10,mod = 998244353;
const long double eps=1e-12;
int p[N];
pii tf(int a,int b,int c,int d)
{
int t =lcm(b,d);
int x = 0;
x+=a*(t/b);
x+=c*(t/d);
return {x,t};
}
void solve()
{
int n;
cin>>n;
int x = sqrt(2*n);
pii ans = tf((x-1),2,n,x);
double tmp = ans.x/ans.y;
for(int i=x;i>=(max(1ll,x-100));i--)
{
if(1.0*(i-1)/2+n/i<tmp)
{
ans=tf((i-1),2,n,i);
tmp=1.0*(i-1)/2+n/i;
}
}
for(int i=x;i<=(min(n,x+100));i++)
{
if(1.0*(i-1)/2+n/i<tmp)
{
ans=tf((i-1),2,n,i);
tmp=1.0*(i-1)/2+n/i;
}
}
int t = gcd(ans.x,ans.y);
ans.x/=t;
ans.y/=t;
cout<<ans.x<<" "<<ans.y<<"\n";
}
/*
2 2 1 1 2 1
*/
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout<<fixed<<setprecision(10);
int t=1;
cin>>t;
while(t--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 462ms
memory: 3704kb
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 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1 1 1 1 1 1 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1 1 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1999961560 44721 19...
result:
ok 1000000 lines
Test #3:
score: -100
Wrong Answer
time: 851ms
memory: 3624kb
input:
1000000 158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784 450968417 430302156 982631932 161735902 880895728 923078537 707723857 189330739 910286918 802329211 404539679 303238506 317063340 492686568 773361868 125...
output:
316511467 17791 877891213 20951 1204845831 34711 49954223 7068 215406386 5189 623676492 17659 433902800 14729 952344999 30860 525355237 22920 211032449 10272 1942776701 44077 251551941 7093 1463896912 38261 1645584679 40566 901913913 30032 107573492 3667 1965228547 44331 323457022 17985 880849567 20...
result:
wrong answer 2nd lines differ - expected: '1755824328 41903', found: '877891213 20951'