QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188309#5491. Spidey DistanceIsaacMoris#WA 1ms3604kbC++141.1kb2023-09-25 18:46:082023-09-25 18:46:08

Judging History

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

  • [2023-09-25 18:46:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3604kb
  • [2023-09-25 18:46:08]
  • 提交

answer

#include<iostream>
#include <bits/stdc++.h>

#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 1e6 + 5, mod = 998244353;


void doWork() {
    ll t, s;
    cin >> t >> s;
    ll ans1 = 1ll * (t + 1) * (t + 2) * 2 - (t + 1) * 4 + 1;
    ll ans2 = 0;

    for (ll x = 0; x <= s; x++) {
        ans2 += min(x, (s - x) * 2) + 1;
        ans2 += max(0ll, (2 * s - x) / 2 - x);
    }
    ans2 = ans2 * 4 - (s + 1) * 4 + 1;

    for (ll x = 0; x <= t; x++) {
        ll r = min(x, t - x);
        ll l = (s - x) * 2;
        ans1 -= max(0ll, r - l) * 4;

        r = min(x - 1, t - x);
        ans1 -= max(0ll, r - l) * 4;
    }
    if (t > s) {
        ans1 += (t - s) * 4;
    }

    ll g = __gcd(ans1, ans2);
    if (ans1 >= ans2) {
        cout << 1;
    } else {
        cout << ans1 / g << "/" << ans2 / g;
    }
}

int main() {
    IO
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4

output:

41/49

result:

ok single line: '41/49'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3428kb

input:

6 6

output:

17/21

result:

ok single line: '17/21'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

3 7

output:

25/141

result:

ok single line: '25/141'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3524kb

input:

7 3

output:

-99/29

result:

wrong answer 1st lines differ - expected: '1', found: '-99/29'