QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#585174#9381. 502 Bad GatewayjihanWA 197ms3696kbC++14881b2024-09-23 19:30:472024-09-23 19:30:47

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-23 19:30:47]
  • 评测
  • 测评结果:WA
  • 用时:197ms
  • 内存:3696kb
  • [2024-09-23 19:30:47]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const long long maxn=1e5+5;
const long long MAX=(long long)INT_MAX*(long long)INT_MAX;
void solve(){
    int n;
    cin >> n;
    int c=sqrt(2*n);
    int c0=c+1;
    int a,b,temp,a0,b0;
    a=c-1;
    b=2;
    temp=__gcd(a,b);
    a/=temp;
    b/=temp;
    a=a*(c)+n*2;
    b*=c;
    temp=__gcd(a,b);
    a/=temp;
    b/=temp;


    a0=c0-1;
    b0=2;
    temp=__gcd(a0,b0);
    a0/=temp;
    b0/=temp;
    a0=a0*(c0)+n*2;
    b0*=c0;
    temp=__gcd(a0,b0);
    a0/=temp;
    b0/=temp;
    if(1.0*a/b>1.0*a0/b0){
        cout << a0  << ' ' << b0 << '\n';
    }
    else{
        cout << a  << ' ' << b << '\n';
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.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: 1ms
memory: 3692kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 197ms
memory: 3696kb

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'