QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583841 | #9381. 502 Bad Gateway | huangce | WA | 166ms | 3648kb | C++17 | 757b | 2024-09-22 23:04:25 | 2024-09-22 23:04:26 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define int ll
using namespace std;
constexpr int N=1e6+7;
constexpr int M=2e3+7;
int t;
void solve()
{
cin>>t;
int c=sqrt(2*t);
int c1=0;
if(c*c!=2*t) c1=c+1;
int fenzi=c*c-c+2*t;
int fenmu=2*c;
int fenzi1=c1*c1-c1+2*t;
int fenmu1=2*c1;
int tt=__gcd(fenzi,fenmu);
fenzi/=tt,fenmu/=tt;
if(c1!=0)
{
int tt1=__gcd(fenzi1,fenmu1);
fenzi1/=tt1,fenmu1/=tt1;
if(fenzi*fenmu1>fenmu*fenzi1)
{
cout<<fenzi<<' '<<fenmu<<endl;
}
else
{
cout<<fenzi1<<' '<<fenmu1<<endl;
}
}
else cout<<fenzi<<' '<<fenmu<<endl;
}
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T=1; cin>>T;
while(T--){solve();}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 166ms
memory: 3648kb
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 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 1 1 1 1 1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 2000006281 44722 1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 2000006281 44722 1 1 2000006281 44722 2000006281 44722 2000006281 44722 20...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '2000006281 44722'