题目链接:http://codeforces.com/contest/976/problem/B
题意:给出个n*m的矩阵,再给出一个k,起始点为(1,1)让你按照蛇那样在矩形中走,问最终位置。
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
LL n,m,k;
while(scanf("%lld%lld%lld",&n,&m,&k)!=EOF)
{
if(k<n) printf("%lld 1\n",k+1);
else
{
k-=n;
LL x=k/(m-1);
printf("%lld ",n-x);
if(x&1) printf("%lld\n",m-k%(m-1));
else printf("%lld\n",k%(m-1)+2);
}
}
return 0;
}