Submission #17461889


Source Code Expand

Copy
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def thresh(A, B):
    # +B よりも A 倍の方が小さいような、最大の x
    l, r = 0, 1 << 60
    while l + 1 < r:
        x = (l + r) // 2
        if x + B > x * A:
            l = x
        else:
            r = x
    return l

def main(X, Y, A, B):
    T = thresh(A, B)
    ans = 0
    while X <= T and X * A < Y:
        X *= A
        ans += 1
    ans += (Y - X - 1) // B
    return ans

print(main(*map(int, read().split())))

Submission Info

Submission Time
Task D - Takahashi Unevolved
User maspy
Language Python (3.8.2)
Score 400
Code Size 587 Byte
Status
Exec Time 29 ms
Memory 9200 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
× 2
× 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, max_01.txt, max_02.txt, max_03.txt, max_04.txt, max_05.txt, max_06.txt, max_07.txt, max_08.txt, max_09.txt, max_10.txt, max_11.txt, max_12.txt, max_13.txt, max_14.txt, max_15.txt, max_16.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt 19 ms 9200 KB
max_01.txt 26 ms 8908 KB
max_02.txt 26 ms 9068 KB
max_03.txt 24 ms 8908 KB
max_04.txt 20 ms 9088 KB
max_05.txt 24 ms 8908 KB
max_06.txt 23 ms 9080 KB
max_07.txt 20 ms 8908 KB
max_08.txt 20 ms 8916 KB
max_09.txt 18 ms 9076 KB
max_10.txt 27 ms 9016 KB
max_11.txt 19 ms 9136 KB
max_12.txt 20 ms 9200 KB
max_13.txt 26 ms 8884 KB
max_14.txt 20 ms 9024 KB
max_15.txt 21 ms 9016 KB
max_16.txt 21 ms 8904 KB
random_01.txt 21 ms 9068 KB
random_02.txt 20 ms 9200 KB
random_03.txt 19 ms 9008 KB
random_04.txt 20 ms 8912 KB
random_05.txt 18 ms 9016 KB
random_06.txt 20 ms 8900 KB
random_07.txt 19 ms 9016 KB
random_08.txt 29 ms 8908 KB
random_09.txt 19 ms 9136 KB
random_10.txt 23 ms 9072 KB
random_11.txt 18 ms 9008 KB
random_12.txt 20 ms 8896 KB
sample_01.txt 27 ms 9136 KB
sample_02.txt 19 ms 9136 KB