QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582655#9381. 502 Bad GatewaycyanacWA 411ms3708kbC++14752b2024-09-22 17:05:122024-09-22 17:05:13

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    int t1=ceil(sqrt(n));
    int t2=floor(sqrt(n));
    int res1=(t1-1)*t1;
    int res2=n*2;
    res1+=res2;
    int k=__gcd(res1,2*t1);
    int ansx=res1/k;
    int ansy=2*t1/k;
    res1=(t2-1)*t2;
    res2=n*2;
    res1+=res2;
    k=__gcd(res1,2*t2);
    int ansxx=res1/k;
    int ansyy=2*t2/k;
    if(double(ansx)/double(ansy)>double(ansxx)/double(ansyy))
    {
        cout<<ansxx<<' '<<ansyy<<endl;
    }
    else cout<<ansx<<' '<<ansy<<endl;

}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin>>T;
    while(T--)
    {
        solve();
    }


}

详细

Test #1:

score: 100
Accepted
time: 0ms
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: 411ms
memory: 3708kb

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
1499991253 31623
1 1
1 1
1499991253 31623
1 1
1499991253 31623
1 1
1 1
1 1
1499991253 31623
1 1
1 1
1499991253 31623
1 1
1499991253 31623
1499991253 31623
1 1
1499991253 31623
1 1
1 1
1499991253 31623
1 1
1499991253 31623
1499991253 31623
1 1
1499991253 31623
1499991253 31623
1499991253 31623
14...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '1499991253 31623'