欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1506A.Strange Table
Strange Table
Polycarp found a rectangular table consisting of rows and columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns":
- cells are numbered starting from one;
- cells are numbered from left to right by columns, and inside each column from top to bottom;
- number of each cell is an integer one greater than in the previous cell.
For example, if and , the table will be numbered as follows:
$$\begin{matrix} 1 & 4 & 7 & 10 & 13 \\ 2 & 5 & 8 & 11 & 14 \\ 3 & 6 & 9 & 12 & 15 \\ \end{matrix}$$</p><p>However, Polycarp considers such numbering inconvenient. He likes the numbering <span class="tex-font-style-bf">"by rows"</span>: </p><ul> <li> cells are numbered starting from one; </li><li> cells are numbered from top to bottom by rows, and inside each row from left to right; </li><li> number of each cell is an integer one greater than the number of the previous cell. </li></ul><p>For example, if$n = 3$and$m = 5$, then Polycarp likes the following table numbering:$$\begin{matrix} 1 & 2 & 3 & 4 & 5 \\ 6 & 7 & 8 & 9 & 10 \\ 11 & 12 & 13 & 14 & 15 \\ \end{matrix}$$</p><p>Polycarp doesn't have much time, so he asks you to find out what would be the cell number in the numbering <span class="tex-font-style-bf">"by rows"</span>, if in the numbering <span class="tex-font-style-bf">"by columns"</span> the cell has the number$x$? ## Input The first line contains a single integer $t$ ($1 \le t \le 10^4$). Then $t$ test cases follow. Each test case consists of a single line containing three integers $n$, $m$, $x$ ($1 \le n, m \le 10^6$, $1 \le x \le n \cdot m$), where $n$ and $m$ are the number of rows and columns in the table, and $x$ is the cell number. Note that the numbers in some test cases do not fit into the $32$-bit integer type, so you must use at least the $64$-bit integer type of your programming language. ## Output For each test case, output the cell number in the numbering "by rows". ## Samples ```input1 5 1 1 1 2 2 3 3 5 11 100 100 7312 1000000 1000000 1000000000000 ``` ```output1 1 2 9 1174 1000000000000 ```$$在线编程 IDE
建议全屏模式获得最佳体验
键盘快捷键
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |
第 1 行,第 1 列
0 字符
-
最近自测结果
暂未运行
最近递交结果
暂无递交记录