A14246 | Strange Table
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Polycarp found a rectangular table consisting of $n$ rows and $m$ 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 $n = 3$ and $m = 5$ , 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} $$
However, Polycarp considers such numbering inconvenient. He likes the numbering **"by rows"**:
- cells are numbered starting from one;
- cells are numbered from top to bottom by rows, and inside each row from left to right;
- number of each cell is an integer one greater than the number of the previous cell.
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} $$
Polycarp doesn't have much time, so he asks you to find out what would be the cell number in the numbering **"by rows"**, if in the numbering **"by columns"** the cell has the number $x$?
- 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 $n = 3$ and $m = 5$ , 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} $$
However, Polycarp considers such numbering inconvenient. He likes the numbering **"by rows"**:
- cells are numbered starting from one;
- cells are numbered from top to bottom by rows, and inside each row from left to right;
- number of each cell is an integer one greater than the number of the previous cell.
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} $$
Polycarp doesn't have much time, so he asks you to find out what would be the cell number in the numbering **"by rows"**, if in the numbering **"by columns"** the cell has the number $x$?
输入格式
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.
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.
输出格式
For each test case, output the cell number in the numbering "by rows".
输入输出样例
输入 #1
5 1 1 1 2 2 3 3 5 11 100 100 7312 1000000 1000000 1000000000000
输出 #1
1 2 9 1174 1000000000000
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted