QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188582#5491. Spidey DistanceGamal74#AC ✓1ms3704kbC++201.8kb2023-09-26 02:44:362023-09-26 02:44:37

Judging History

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

  • [2023-09-26 02:44:37]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3704kb
  • [2023-09-26 02:44:36]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define fi first
#define se second
#define pp push_back
#define all(x) (x).begin(), (x).end()
#define Ones(n) __builtin_popcount(n)
#define endl '\n'
#define mem(arrr, xx) memset(arrr,xx,sizeof arrr)
//#define int long long
#define debug(x) cout << (#x) << " = " << x << endl

void Gamal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef Clion
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}

int dx[] = {+0, +0, -1, +1, +1, +1, -1, -1};
int dy[] = {-1, +1, +0, +0, +1, -1, +1, -1};

const double EPS = 1e-9;
const ll OO = 0X3F3F3F3F3F3F3F3F;
const int N = 2e5 + 5, INF = INT_MAX, MOD = 1e9 + 7, LOG = 20;


void solve() {
    int t, s;
    cin >> t >> s;
    s *= 2;
    ll den = s / 2;
    for (int x = 1; 2 * x <= s; ++x) {
        // if x is max
        ll rem = min(s - 2 * x, x);
        den += max(rem, 0ll);
        // if x is min
        ll l = x + 1, r = (s - x) / 2;
        den += max(r - l + 1, 0ll);
    }
    den *= 4;
    den++;
    ll num = min(s/2,t);
    for (int x = 1; 2 * x <= s; ++x) {
        // if x is max
        ll rem = min({s - 2 * x, x,t - x});
        num += max(rem, 0ll);
        ll l = x + 1, r = min((s - x) / 2,t - x);
        num += max(r - l + 1, 0ll);
    }
    num *= 4;
    num++;
    ll gd = gcd(num,den);
    num /= gd;
    den /= gd;
    if(den == 1){
        cout << num;
        return;
    }
    cout << num << "/" << den;


}


signed main() {
    Gamal();
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4

output:

41/49

result:

ok single line: '41/49'

Test #2:

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

input:

6 6

output:

17/21

result:

ok single line: '17/21'

Test #3:

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

input:

3 7

output:

25/141

result:

ok single line: '25/141'

Test #4:

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

input:

7 3

output:

1

result:

ok single line: '1'

Test #5:

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

input:

10 9

output:

209/229

result:

ok single line: '209/229'

Test #6:

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

input:

0 1000000

output:

1/2666668000001

result:

ok single line: '1/2666668000001'

Test #7:

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

input:

1000000 0

output:

1

result:

ok single line: '1'

Test #8:

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

input:

1000000 1000000

output:

2000002000001/2666668000001

result:

ok single line: '2000002000001/2666668000001'

Test #9:

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

input:

0 0

output:

1

result:

ok single line: '1'

Test #10:

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

input:

10000 7501

output:

150049997/150050005

result:

ok single line: '150049997/150050005'

Test #11:

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

input:

10000 8000

output:

168012001/170677333

result:

ok single line: '168012001/170677333'

Test #12:

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

input:

10000 8500

output:

182014001/192678001

result:

ok single line: '182014001/192678001'

Test #13:

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

input:

10000 9000

output:

192016001/216012001

result:

ok single line: '192016001/216012001'

Test #14:

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

input:

10000 9500

output:

198018001/240679333

result:

ok single line: '198018001/240679333'

Test #15:

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

input:

10000 9999

output:

200019989/266626669

result:

ok single line: '200019989/266626669'

Test #16:

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

input:

10000 10000

output:

200020001/266680001

result:

ok single line: '200020001/266680001'

Test #17:

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

input:

0 10000

output:

1/266680001

result:

ok single line: '1/266680001'

Test #18:

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

input:

10000 0

output:

1

result:

ok single line: '1'

Test #19:

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

input:

1000000 750000

output:

1

result:

ok single line: '1'

Test #20:

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

input:

1000000 999999

output:

2000001999989/2666662666669

result:

ok single line: '2000001999989/2666662666669'

Test #21:

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

input:

1000000 750001

output:

1500004999997/1500005000005

result:

ok single line: '1500004999997/1500005000005'

Test #22:

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

input:

1000000 875001

output:

1875003499997/2041672500005

result:

ok single line: '1875003499997/2041672500005'