QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#585161#9381. 502 Bad GatewayjihanWA 171ms3604kbC++14888b2024-09-23 19:26:212024-09-23 19:26:22

Judging History

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

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

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=(int)sqrt(2.0*n);
    int c0=c++;
    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;
}

詳細信息

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 171ms
memory: 3556kb

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'