QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188316 | #5491. Spidey Distance | IsaacMoris# | AC ✓ | 3ms | 3704kb | C++14 | 1.2kb | 2023-09-25 18:52:45 | 2023-09-25 18:52:45 |
Judging History
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 = max(0ll, (s - x) * 2);
ans1 -= max(0ll, r - l) * 4;
}
for (ll y = 0; y <= t; y++) {
ll r = min(y - 1, t - y);
ll l = max(0ll, (s - y) * 2);
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: 3592kb
input:
4 4
output:
41/49
result:
ok single line: '41/49'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
6 6
output:
17/21
result:
ok single line: '17/21'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
3 7
output:
25/141
result:
ok single line: '25/141'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
7 3
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
10 9
output:
209/229
result:
ok single line: '209/229'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
0 1000000
output:
1/2666668000001
result:
ok single line: '1/2666668000001'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3640kb
input:
1000000 0
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 3ms
memory: 3640kb
input:
1000000 1000000
output:
2000002000001/2666668000001
result:
ok single line: '2000002000001/2666668000001'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
0 0
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
10000 7501
output:
150049997/150050005
result:
ok single line: '150049997/150050005'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3624kb
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: 3580kb
input:
10000 9000
output:
192016001/216012001
result:
ok single line: '192016001/216012001'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3560kb
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: 3576kb
input:
10000 10000
output:
200020001/266680001
result:
ok single line: '200020001/266680001'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3640kb
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: 3ms
memory: 3640kb
input:
1000000 750000
output:
1
result:
ok single line: '1'
Test #20:
score: 0
Accepted
time: 3ms
memory: 3628kb
input:
1000000 999999
output:
2000001999989/2666662666669
result:
ok single line: '2000001999989/2666662666669'
Test #21:
score: 0
Accepted
time: 3ms
memory: 3704kb
input:
1000000 750001
output:
1500004999997/1500005000005
result:
ok single line: '1500004999997/1500005000005'
Test #22:
score: 0
Accepted
time: 3ms
memory: 3600kb
input:
1000000 875001
output:
1875003499997/2041672500005
result:
ok single line: '1875003499997/2041672500005'