Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'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": 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": 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 <= t <= 10^4 ). Then t test cases follow. Each test case consists of a single line containing three integers n , m , x ( 1 <= n, m <= 10^6 , 1 <= x <= 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". '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
111061621 |
AGurindapalli |
A |
March 25, 2021, 4:39 p.m. |
OK |
.NET Core C# |
TESTS |
5 |
108 |
3788800 |
|
|
remove filters
Back to search problems