QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#883 | #582823 | #9381. 502 Bad Gateway | chenzq7 | jack | Failed. | 2024-09-22 18:26:50 | 2024-09-22 18:26:50 |
Details
Extra Test:
Accepted
time: 0ms
memory: 3660kb
input:
1 1
output:
1 1
result:
ok single line: '1 1'
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#582823 | #9381. 502 Bad Gateway | jack | AC ✓ | 236ms | 3668kb | C++14 | 781b | 2024-09-22 17:33:26 | 2024-09-24 14:56:49 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
void solve()
{
int n;
cin>>n;
ll p=(ll)sqrt((ll)2*n);
ll q=p+1;
ll f1=p*p-p+2*n;
ll s1=2*p;
double h=1.0*f1/s1;
ll f2=q*q-q+2*n;
ll s2=2*q;
double h1=1.0*f2/s2;
// cout<<h<<' '<<h1<<endl;
if(q>n)
{
h1=1e18;
}
//cout<<f2/__gcd(f2,s2)<<' '<<s2/__gcd(f2,s2)<<'\n';
if(h<=h1)
{
cout<<f1/__gcd(f1,s1)<<' '<<s1/__gcd(f1,s1)<<'\n';
}else
{
cout<<f2/__gcd(f2,s2)<<' '<<s2/__gcd(f2,s2)<<'\n';
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--) solve();
return 0;
}