QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#585254#9381. 502 Bad GatewayCoffeecat996WA 214ms3640kbC++141.8kb2024-09-23 19:57:442024-09-23 19:57:45

Judging History

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

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

answer

// !红色注释
// ?蓝色注释
// //灰色删除线注释
// todo 橘红色注释
//*浅绿色注释
/**
 * @file    :b.cpp
 * @author  :Coffeecat996
 * @version :V1.0.0
 * @date    :2024-09-23
 */
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve()
{
    int t;
    cin >> t;
    int c1 = (int)(sqrt(t * 2));
    int c2= (int)(sqrt(t * 2))+((pow((int)(sqrt(t * 2)),2)==t*2)?0:1);
    // cout<< c1 << " " << c2 << "???"<<endl;
    // cout << "t:" << t << " c:" << c << endl;
    double ans1, ans2;
    // cout<< c1 << " " << c2 << endl;
    // return;
    ans1 = (c1 - 1) / 2 + t / c1;
    ans2 = (c2 - 1) / 2 + t / c2;
    // cout<< ans1 << " " << ans2 <<"??" <<endl;
    int fz, fm;
    if(ans1<ans2)
    {
        pair<int, int> a = {c1 - 1, 2};
        pair<int, int> b = {t, c1};
        int gcd= __gcd(a.first, a.second);
        a.first /= gcd;
        a.second /= gcd;
        gcd = __gcd(b.first, b.second);
        b.first /= gcd;
        b.second /= gcd;
        fz = a.first * b.second + a.second * b.first;
        fm = a.second * b.second;
        gcd= __gcd(fz, fm);
        cout << fz / gcd << " " << fm / gcd << endl;
    }
    else
    {
        pair<int, int> a = {c2 - 1, 2};
        pair<int, int> b = {t, c2};
        int gcd = __gcd(a.first, a.second);
        a.first /= gcd;
        a.second /= gcd;
        gcd = __gcd(b.first, b.second);
        b.first /= gcd;
        b.second /= gcd;
        fz = a.first * b.second + a.second * b.first;
        fm = a.second * b.second;
        gcd = __gcd(fz, fm);
        cout << fz / gcd << " " << fm / gcd << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 214ms
memory: 3640kb

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'