305121: CF976B. Lara Croft and the New Game

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Lara Croft and the New Game

题意翻译

给定一个n*m的矩阵(n保证是偶数),现在zyk从左上角起点(1, 1)出发,要走到终点(1, 2)。走法如下:首先zyk从(1, 1)向下一直走到(n, 1),然后从(n, 1)向右一直走到(n, m),之后不断按照S型方式走,也就是先向上走一步到(n-1, m),然后从(n-1, m)走到(n-1, 2),再向上走一步到(n-2, 2),再向右走到(n-2, m),……,一直走到(2, m),在向上一步走到(1, m),最后向左走到终点(1, 2)。 ![](http://luo.hustoj.com/upload/201805/image/cf976B.png) 问当走到第k步的时候,zyk位置坐标是什么。 上例中,k=0时,zyk在(1, 1),k=11时, zyk在(1, 2)。

题目描述

You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy. Lara is going to explore yet another dangerous dungeon. Game designers decided to use good old 2D environment. The dungeon can be represented as a rectangle matrix of $ n $ rows and $ m $ columns. Cell $ (x,y) $ is the cell in the $ x $ -th row in the $ y $ -th column. Lara can move between the neighbouring by side cells in all four directions. Moreover, she has even chosen the path for herself to avoid all the traps. She enters the dungeon in cell $ (1,1) $ , that is top left corner of the matrix. Then she goes down all the way to cell $ (n,1) $ — the bottom left corner. Then she starts moving in the snake fashion — all the way to the right, one cell up, then to the left to the cell in $ 2 $ -nd column, one cell up. She moves until she runs out of non-visited cells. $ n $ and $ m $ given are such that she always end up in cell $ (1,2) $ . Lara has already moved to a neighbouring cell $ k $ times. Can you determine her current position?

输入输出格式

输入格式


The only line contains three integers $ n $ , $ m $ and $ k $ ( $ 2<=n,m<=10^{9} $ , $ n $ is always even, $ 0<=k<n·m $ ). Note that $ k $ doesn't fit into $ 32 $ -bit integer type!

输出格式


Print the cell (the row and the column where the cell is situated) where Lara ends up after she moves $ k $ times.

输入输出样例

输入样例 #1

4 3 0

输出样例 #1

1 1

输入样例 #2

4 3 11

输出样例 #2

1 2

输入样例 #3

4 3 7

输出样例 #3

3 2

说明

Here is her path on matrix $ 4 $ by $ 3 $ : ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF976B/1b2df8f31f927201c078b0cd1ef3dccbc8991311.png)

Input

题意翻译

给定一个n*m的矩阵(n保证是偶数),现在zyk从左上角起点(1, 1)出发,要走到终点(1, 2)。走法如下:首先zyk从(1, 1)向下一直走到(n, 1),然后从(n, 1)向右一直走到(n, m),之后不断按照S型方式走,也就是先向上走一步到(n-1, m),然后从(n-1, m)走到(n-1, 2),再向上走一步到(n-2, 2),再向右走到(n-2, m),……,一直走到(2, m),在向上一步走到(1, m),最后向左走到终点(1, 2)。 ![](http://luo.hustoj.com/upload/201805/image/cf976B.png) 问当走到第k步的时候,zyk位置坐标是什么。 上例中,k=0时,zyk在(1, 1),k=11时, zyk在(1, 2)。

加入题单

上一题 下一题 算法标签: