QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#155324 | #2164. Landscape Generator | warwolf# | WA | 15ms | 9032kb | Python3 | 1.2kb | 2023-09-01 15:52:40 | 2023-09-01 15:52:40 |
Judging History
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)
詳細信息
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: ''