QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#809232#9864. CoinhsnCompile Error//C++23642b2024-12-11 13:24:472024-12-11 13:24:49

Judging History

This is the latest submission verdict.

  • [2024-12-11 13:24:49]
  • Judged
  • [2024-12-11 13:24:47]
  • Submitted

answer

import math

def find_last_ans(n, k):
    if k > n / 2:
        return n
    c = k - 1
    ans = 1
    last_ans = 1
    while ans <= n:
        m = math.ceil(ans / c)
        next_multiple = math.ceil(ans / c) * c
        s = min((next_multiple - ans - 1) // m + 1, (n - ans) // m)
        if s <= 0:
            if ans + m <= n:
                ans += m
                last_ans = ans
            else:
                break
        else:
            ans += s * m
            last_ans = ans
    return last_ans

t = int(input())
for _ in range(t):
    n, k = map(int, input().split())
    print(find_last_ans(n, k))

详细

answer.code:1:1: error: ‘import’ does not name a type
    1 | import math
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’, which is not yet enabled with ‘-std=c++20’