1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/乐团站位 [SNJvJP].md
2022-03-29 12:43:11 +08:00

30 lines
945 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

某乐团的演出场地可视作 `num * num` 的二维矩阵 `grid`(左上角坐标为 `[0,0]`),每个位置站有一位成员。乐团共有 `9` 种乐器,乐器编号为 `1~9`,每位成员持有 `1` 个乐器。
为保证声乐混合效果,成员站位规则为:自 `grid` 左上角开始顺时针螺旋形向内循环以 `12...9` 循环重复排列。例如当 num = `5` 时,站位如图所示
![image.png](https://pic.leetcode-cn.com/1616125411-WOblWH-image.png)
请返回位于场地坐标 [`Xpos`,`Ypos`] 的成员所持乐器编号。
**示例 1**
>输入:`num = 3, Xpos = 0, Ypos = 2`
>
>输出:`3`
>
>解释:
![image.png](https://pic.leetcode-cn.com/1616125437-WUOwsu-image.png)
**示例 2**
>输入:`num = 4, Xpos = 1, Ypos = 2`
>
>输出:`5`
>
>解释:
![image.png](https://pic.leetcode-cn.com/1616125453-IIDpxg-image.png)
**提示:**
- `1 <= num <= 10^9`
- `0 <= Xpos, Ypos < num`