QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188465#5491. Spidey Distancetriplem5dsAC ✓74ms3716kbC++232.1kb2023-09-25 21:03:482023-09-25 21:03:49

Judging History

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

  • [2023-09-25 21:03:49]
  • 评测
  • 测评结果:AC
  • 用时:74ms
  • 内存:3716kb
  • [2023-09-25 21:03:48]
  • 提交

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 (ans1 == 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: 24ms
memory: 3660kb

input:

4 4

output:

41/49

result:

ok single line: '41/49'

Test #2:

score: 0
Accepted
time: 24ms
memory: 3664kb

input:

6 6

output:

17/21

result:

ok single line: '17/21'

Test #3:

score: 0
Accepted
time: 24ms
memory: 3712kb

input:

3 7

output:

25/141

result:

ok single line: '25/141'

Test #4:

score: 0
Accepted
time: 24ms
memory: 3716kb

input:

7 3

output:

1

result:

ok single line: '1'

Test #5:

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

input:

10 9

output:

209/229

result:

ok single line: '209/229'

Test #6:

score: 0
Accepted
time: 58ms
memory: 3592kb

input:

0 1000000

output:

1/2666668000001

result:

ok single line: '1/2666668000001'

Test #7:

score: 0
Accepted
time: 24ms
memory: 3660kb

input:

1000000 0

output:

1

result:

ok single line: '1'

Test #8:

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

input:

1000000 1000000

output:

2000002000001/2666668000001

result:

ok single line: '2000002000001/2666668000001'

Test #9:

score: 0
Accepted
time: 25ms
memory: 3596kb

input:

0 0

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 21ms
memory: 3712kb

input:

10000 7501

output:

150049997/150050005

result:

ok single line: '150049997/150050005'

Test #11:

score: 0
Accepted
time: 25ms
memory: 3660kb

input:

10000 8000

output:

168012001/170677333

result:

ok single line: '168012001/170677333'

Test #12:

score: 0
Accepted
time: 25ms
memory: 3712kb

input:

10000 8500

output:

182014001/192678001

result:

ok single line: '182014001/192678001'

Test #13:

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

input:

10000 9000

output:

192016001/216012001

result:

ok single line: '192016001/216012001'

Test #14:

score: 0
Accepted
time: 25ms
memory: 3708kb

input:

10000 9500

output:

198018001/240679333

result:

ok single line: '198018001/240679333'

Test #15:

score: 0
Accepted
time: 26ms
memory: 3592kb

input:

10000 9999

output:

200019989/266626669

result:

ok single line: '200019989/266626669'

Test #16:

score: 0
Accepted
time: 25ms
memory: 3580kb

input:

10000 10000

output:

200020001/266680001

result:

ok single line: '200020001/266680001'

Test #17:

score: 0
Accepted
time: 25ms
memory: 3580kb

input:

0 10000

output:

1/266680001

result:

ok single line: '1/266680001'

Test #18:

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

input:

10000 0

output:

1

result:

ok single line: '1'

Test #19:

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

input:

1000000 750000

output:

1

result:

ok single line: '1'

Test #20:

score: 0
Accepted
time: 74ms
memory: 3600kb

input:

1000000 999999

output:

2000001999989/2666662666669

result:

ok single line: '2000001999989/2666662666669'

Test #21:

score: 0
Accepted
time: 48ms
memory: 3580kb

input:

1000000 750001

output:

1500004999997/1500005000005

result:

ok single line: '1500004999997/1500005000005'

Test #22:

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

input:

1000000 875001

output:

1875003499997/2041672500005

result:

ok single line: '1875003499997/2041672500005'