QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#715747 | #9381. 502 Bad Gateway | Stargazer# | WA | 353ms | 3684kb | C++20 | 1.4kb | 2024-11-06 13:15:12 | 2024-11-06 13:15:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
#define gc getchar
inline int read(){
char ch=gc();
int res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
inline ll readll(){
char ch=gc();
ll res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}
int n;
#define pll pair<ll,ll>
pll calc(int r){
pll x;
x.fi=1ll*r*(r+1)/2+n-r,x.se=r;
return x;
}
bool check(int k){
pll x=calc(k);
pll y=calc(k+1);
if(x.fi*y.se<=x.se*y.fi)return true;
else return false;
}
void solve(){
n=read();
int l=1,r=n-1,res=n;
while(l<=r){
int mid=(l+r)/2;
if(check(mid))res=mid,r=mid-1;
else l=mid+1;
}
//pll a=calc(1),b=calc(2);
//cout<<a.fi<<" "<<a.se<<" "<<b.fi<<" "<<b.se<<'\n';
pll rr=calc(res);
ll g=__gcd(rr.fi,rr.se);
// cout<<res<<'\n';
cout<<rr.fi/g<<" "<<rr.se/g<<'\n';
}
int main(){
#ifdef Stargazer
freopen("1.in","r",stdin);
#endif
int T=read();
while(T--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3684kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 173ms
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 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: 353ms
memory: 3628kb
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 1755824328 41903 1204845831 34711 49954223 7068 1723292600 41513 623676492 17659 867864517 29460 952375859 30861 262700539 11461 422085442 20545 1942776701 44077 251551941 7093 1463896912 38261 1645584679 40566 901913913 30032 107573492 3667 1965228547 44331 323457022 17985 176178307...
result:
wrong answer 41st lines differ - expected: '1908546898 43687', found: '128508021701063017 506967496'