用 pos 表示当前位置,下标范围为 0 到 n-1。
pos
0
n-1
pos = (pos - s % n + n) % n
pos = (pos + s) % n
每条口令只处理一次,时间复杂度为 O(n+m)。
O(n+m)
使用您的 星源智一OJ 通用账户