QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#586223#9381. 502 Bad GatewayaurorawhiteseaWA 384ms3636kbC++201.0kb2024-09-24 09:01:552024-09-24 09:01:56

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-24 09:01:56]
  • 评测
  • 测评结果:WA
  • 用时:384ms
  • 内存:3636kb
  • [2024-09-24 09:01:55]
  • 提交

answer

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <numeric>
using namespace std;
void speed()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}

int gcd(int a, int b)
{
    if( b == 0 )
        return a;
    return gcd(b, a % b);
}
int main()
{
    speed();
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int x1 = floor(sqrt(2*n));
        int x2 = ceil(sqrt(2*n));
        int a1 = x1*x1 + 2*n - x1;
        int b1 = 2 * x1;
        int g = gcd(a1, b1);
        a1 /= g, b1 /= g;

        int a2 = x2*x2 + 2 *n - x2;
        int b2 = 2 * x2;
        g = gcd(a2, b2);
        a2 /= g, b2 /= g;

        if( a1 * b2 < a2 * b1)
        {
            cout << a1<<" "<<b1<<endl;
        }
        else
        {
            cout << a2<<" "<<b2<<endl;
        }
    }





    return 0;
}

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 384ms
memory: 3572kb

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
147522088 -44721
1 1
1 1
147522088 -44721
1 1
147522088 -44721
1 1
1 1
1 1
147522088 -44721
1 1
1 1
147522088 -44721
1 1
147522088 -44721
147522088 -44721
1 1
147522088 -44721
1 1
1 1
147522088 -44721
1 1
147522088 -44721
147522088 -44721
1 1
147522088 -44721
147522088 -44721
147522088 -44721
14...

result:

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