QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#155324#2164. Landscape Generatorwarwolf#WA 15ms9032kbPython31.2kb2023-09-01 15:52:402023-09-01 15:52:40

Judging History

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

  • [2023-09-01 15:52:40]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:9032kb
  • [2023-09-01 15:52:40]
  • 提交

answer

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def exgcd(a, b):
    if b == 0:
        return 1, 0
    else:
        y, x = exgcd(b, a % b)
        y -= a // b * x
        return x, y

def check(mid, b, d, a):
    c = 0
    e = 1
    for i in range(0, mid):
        c = c * 10 + d
        e = e * 10
    # print(c)
    g = gcd(b, e)
    if c % g != 0:
        return False
    x, y = exgcd(b, -e)
    # print(x, y, x * b - e * y)
    x = x * (c // g)
    y = y * (c // g)
    if b * x -  e * y < 0:
        x = -x
        y = -y
    # print(x, x * b, y * e, c, b * x - e * y)
    dx, dy = e // abs(g), b // abs(g)
    y = (y % dy + dy) % dy
    x = (c + e * y) // b
    if x == 0:
        x += e
    # print(x, x * b, y * e, c, b * x - e * y)
    return x * b <= a

if __name__ == '__main__':
    x = input().split()
    b, d = int(x[0]), int(x[1])
    # print(b, d, a)
    # a = pow(10, 10000);

    # l, r = 0, 10000
    # ans = 0
    # while l <= r:
    #     mid = (l + r) // 2
    #     if check(mid, b, d, a):
    #         ans = mid
    #         l = mid + 1
    #     else :
    #         r = mid - 1

    # print(ans)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 15ms
memory: 9032kb

input:

71 1487
H 20 68
D 22 52
H 39 55
V 8 58
V 56 61
V 1 30
V 3 11
V 40 49
H 4 24
H 27 68
H 28 36
R 7 30
V 4 42
V 9 24
D 7 15
R 2 31
V 29 51
R 9 11
V 69 69
R 65 70
H 2 56
V 21 22
D 23 35
H 23 47
D 59 60
D 16 50
V 3 26
V 64 70
H 28 31
R 24 25
H 4 70
D 1 42
D 39 39
D 11 33
V 16 68
H 53 71
V 2 71
H 26 47
H 5...

output:


result:

wrong answer 1st lines differ - expected: '-2', found: ''