QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582722#9381. 502 Bad GatewayjackWA 170ms3652kbC++14686b2024-09-22 17:16:232024-09-22 17:16:25

Judging History

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

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

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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 170ms
memory: 3652kb

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'