QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188463 | #5491. Spidey Distance | triplem5ds# | WA | 57ms | 3700kb | C++23 | 2.1kb | 2023-09-25 21:02:13 | 2023-09-25 21:02:13 |
Judging History
answer
/// Msaa el 5ra
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for(int i = a; i < b; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll
using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;
const int N = 5e5 + 5, LG = 18, MOD = 1e9 + 7;
const long double PI = acos(-1);
const long double EPS = 1e-7;
int cnt[3005];
int cnt2[3005];
void doWork() {
int t, s;
cin >> t >> s;
ll ans1 = 1, ans2 = 1;
///(x*3/2)+md<=s
for (int x = 1; x <= 1000000; x++) {
if (x * 3 <= s * 2) {
ans1 += 4;
if (x * 2 <= t) {
ans2 += 4;
}
};
if (x <= s) {
ans1 += 4;
if (x <= t) {
ans2 += 4;
}
}
int lo = 0, hi = 1000000;
while (lo < hi) {
int md = lo + (hi - lo + 1) / 2;
if (x * 3 + md * 2 <= s * 2)
lo = md;
else
hi = md - 1;
}
int A = lo;
ans1 += lo * 8;
{
int lo = 0, hi = A;
while (lo < hi) {
int md = lo + (hi - lo + 1) / 2;
if (md + x * 2 <= t)
lo = md;
else
hi = md - 1;
}
ans2 += lo * 8;
}
}
// cout << ans1 << ' ' << ans2 << endl;
int g = __gcd(ans1, ans2);
ans1 /= g;
ans2 /= g;
if (ans2 == 1)cout << ans1 << '\n';
else
cout << ans2 << "/" << ans1 << '\n';
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
int t = 1;
// cin >> t;
while (t--) {
doWork();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 30ms
memory: 3584kb
input:
4 4
output:
41/49
result:
ok single line: '41/49'
Test #2:
score: 0
Accepted
time: 30ms
memory: 3588kb
input:
6 6
output:
17/21
result:
ok single line: '17/21'
Test #3:
score: 0
Accepted
time: 31ms
memory: 3644kb
input:
3 7
output:
25/141
result:
ok single line: '25/141'
Test #4:
score: 0
Accepted
time: 31ms
memory: 3700kb
input:
7 3
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 30ms
memory: 3632kb
input:
10 9
output:
209/229
result:
ok single line: '209/229'
Test #6:
score: -100
Wrong Answer
time: 57ms
memory: 3640kb
input:
0 1000000
output:
2666668000001
result:
wrong answer 1st lines differ - expected: '1/2666668000001', found: '2666668000001'