QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#582788#9381. 502 Bad GatewayjackWA 174ms3676kbC++14686b2024-09-22 17:27:222024-09-22 17:27:22

Judging History

你现在查看的是最新测评结果

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 17:27:22]
  • 评测
  • 测评结果:WA
  • 用时:174ms
  • 内存:3676kb
  • [2024-09-22 17:27:22]
  • 提交

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=double(f1/s1);
    ll f2=q*q-q+2*n;
    ll s2=2*q;
    double h1=double(f2/s2);
    if(q>n)
    {
       h1=1e18;   
    }
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3568kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 174ms
memory: 3676kb

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'