QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#585178#9381. 502 Bad GatewayjihanWA 194ms3604kbC++14881b2024-09-23 19:33:092024-09-23 19:33:10

Judging History

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

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

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const long long maxn=1e6+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: 0ms
memory: 3508kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 194ms
memory: 3604kb

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'