QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#216835#7178. Bishopscardinal_city#Compile Error//C++23678b2023-10-16 01:54:572023-10-16 01:54:57

Judging History

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

  • [2023-10-16 01:54:57]
  • 评测
  • [2023-10-16 01:54:57]
  • 提交

answer

[n, m] = map(int, input().split())

if n % m == 0 or m % n == 0:
    print(n + m - 2)
else:
    print(n + m - 1)

def get_pairs(a, b):
    if a > b:
        return [(t[1], t[0]) for t in get_pairs(b, a)]
    elif a == 1:
        return [(1, k) for k in range(1, b + 1)]
    elif a == b:
        ans = [(k, 1) for k in range(1, a + 1)]
        ans += [(k, b) for k in range(2, a)]
        return ans
    else:
        num = b // a
        ans = [(k, 1 + a * x) for k in range(1, a + 1) for x in range(num)]
        ans += [(t[0], t[1] + a * num) for t in get_pairs(a, b % a)]
        return ans

ans = get_pairs(n, m)
for t in ans:
    print(t[0], t[1])

Details

answer.code:1:1: error: expected unqualified-id before ‘[’ token
    1 | [n, m] = map(int, input().split())
      | ^