QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#583286#9381. 502 Bad GatewayLightFeatherWA 162ms3576kbC++201.0kb2024-09-22 19:24:382024-09-22 19:24:38

Judging History

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

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

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;

constexpr int N = 1e4 + 10;

void solve() {
    int t;
    cin >> t;
    int c = sqrt(2 * t);
    int ct = c, cb = min(c + 1, t);
    if(ct * ct == t)
        cb = ct;
    int it = t;
    int fz1 = ct * ct - ct + 2 * it;
    int fm1 = 2 * ct;
    int fz2 = cb * cb - cb + 2 * it;
    int fm2 = 2 * cb;
    int cmp1 = fz1 * fm2, cmp2 = fz2 * fm1;
    int fz, fm;
    if(cmp1 >= cmp2) {
        fz = fz1, fm = fm1;
        fz /= __gcd(fz1, fm1);
        fm /= __gcd(fz1, fm1);
    }
    else {
        fz = fz2, fm = fm2;
        fz /= __gcd(fz2, fm2);
        fm /= __gcd(fz2, fm2);
    }
    cout << fz << " " << fm << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    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: 3552kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 162ms
memory: 3576kb

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'