CF # 389 Santa Claus and a Place in a Class
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there aren lanes ofm desks each, and there are two working places at each of the desks. The lanes are numbered from1 ton from the left to the right, the desks in a lane are numbered from1 tom starting from the blackboard. Note that the lanes go perpendicularly to the blackboard, not along it (see picture).
The organizers numbered all the working places from 1 to2nm. The places are numbered by lanes (i. e. all the places of the first lane go first, then all the places of the second lane, and so on), in a lane the places are numbered starting from the nearest to the blackboard (i. e. from the first desk in the lane), at each desk, the place on the left is numbered before the place on the right.
The picture illustrates the first and the second samples.
Santa Clause knows that his place has number k. Help him to determine at which lane at which desk he should sit, and whether his place is on the left or on the right!
Input
The only line contains three integers n,m andk (1 ≤ n, m ≤ 10 000,1 ≤ k ≤ 2nm) — the number of lanes, the number of desks in each lane and the number of Santa Claus’ place.
Output
Print two integers: the number of lane r, the number of deskd, and a characters, which stands for the side of the desk Santa Claus. The characters should be “L”, if Santa Clause should sit on the left, and “R” if his place is on the right.
Example
Input
4 3 9
Output
2 2 L
Input
4 3 24
Output
4 3 R
Input
2 4 4
Output
1 2 R
Note
The first and the second samples are shown on the picture. The green place corresponds to Santa Claus’ place in the first example, the blue place corresponds to Santa Claus’ place in the second example.
In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his place is in the first lane at the second desk on the right.
/*
题目大意:根据序号确定坐标,类比平时坐座位形象,输出其几行、几列以及左右,简单题,但是注意对时间的控制。
*/
#include<cstdio> //超时,可能是因为判断条件太多导致
int main()
{
int n,m,k;
int first,second,t; //first代表输出的行,second代表输出的列,char代表左or右;
char c;
while(scanf("%d%d%d",&n,&m,&k)){
if(k&1){ //判断奇偶性
first=k/(2*m)+1;
t=k%(2*m);
if(t%2==0) second=t/2;
else second=t/2+1;
}
else{
first=k/(2*m);
second=m;
}
if(k&1) c='L';
else c='R';
printf("%d %d %c\n",first,second,c);
}
return 0;
}
/*
这是一个数学问题,只要稍微推导一下,就可以找到规律;
*/
//给一段AC代码,计算方法是一样的,不过这段代码简单,总结一下:可能我的代码没有优化导致超时;
#include<cstdio>
int main()
{
int n,m,k;
scanf("%d %d %d",&n,&m,&k);
int r=(k-1)/(2*m); //(k-1)相当于k,这是他处理的巧妙之处
int d=(k-1)%(2*m);
if(k%2==0)
{
printf("%d %d R\n",r+1,d/2+1);
}
else
{
printf("%d %d L\n",r+1,d/2+1);
}
return 0;
} //代码简单,省去了很多不必要的写法
/*以后写题要注意优化代码,简化步骤。