QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581994#9381. 502 Bad GatewaySMTTYWA 220ms3800kbC++14645b2024-09-22 14:54:212024-09-22 14:54:22

Judging History

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

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

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

typedef long long ll;

ll calc(ll c, ll t){
    return c * c * t + 2 * c * c + 2 * t * t - 3 * c * t;
}

void solve(){
    ll t, x, y, c;
    scanf("%lld", &t);
    x = sqrt(2 * t), y = x + 1;
    // x = sqrt(t * t * 2 / (2 + t)), y = x + 1;
    if (calc(x, t) * y < calc(y, t) * x) c = x;
    else c = y;
    c = t;
    ll ans1 = calc(c, t), ans2 = 2 * t * c;
    ll gcd = __gcd(ans1, ans2);
    printf("%lld %lld\n", ans1 / gcd, ans2 / gcd);
}

int main(){
    int _;
    scanf("%d", &_);
    while (_ -- ) solve();
}

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 220ms
memory: 3800kb

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
-22624583539751 7629394531250
1 1
1 1
-22624583539751 7629394531250
1 1
-22624583539751 7629394531250
1 1
1 1
1 1
-22624583539751 7629394531250
1 1
1 1
-22624583539751 7629394531250
1 1
-22624583539751 7629394531250
-22624583539751 7629394531250
1 1
-22624583539751 7629394531250
1 1
1 1
-2262458...

result:

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