欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CodeForces - 752ASanta Claus and a Place in a Class 老人选座位(细节)

程序员文章站 2022-06-11 12:09:38
...

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 are n lanes of m desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to n from the left to the right, the desks in a lane are numbered from 1 to mstarting 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 to 2nm. 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.

CodeForces - 752ASanta Claus and a Place in a Class 老人选座位(细节)                                                                                                                    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 nm and k (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 desk d, and a character s, which stands for the side of the desk Santa Claus. The character s should be "L", if Santa Clause should sit on the left, and "R" if his place is on the right.

Examples

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.

题意:

这道题可以结合上面的那一张图来看,输入的为n,m,k,n指的是列数,m指的是hi行数,k指的是老人想选的位置号,输出的是r,d,s,r指的是行数,d指的是列数,s指的是该位置的左边还是右边。

思路:

这道题应该是比较水的,其实理解了提议以后就非常简单,主要分奇偶讨论和考虑到每个列数的最后一个偶数位置,和第一列的情况,这四类能够讨论清楚的话,基本上也就可以做出来了。

代码:

#include<bits/stdc++.h>
using namespace std;
int n,m,k;//n表示横向列数,m表示纵向行数,k表示是第几个数
int r,d;;//r表示横向第几列,d表示纵向第几行
char s;//表示左右 
int main()
{
	while(~scanf("%d%d%d",&n,&m,&k))//输入题目所要求的这三个数 
	{
		if(k%2==0&&k%(2*m)==0)//当k是偶数,且k是列数的最后一个的时候 
		{
			r=k/(2*m);
			s='R';
		}
		else if(k%2==0&&k%(2*m)!=0)//当k是偶数,且k不是列数的最后一个的时候 
		{
			r=k/(2*m)+1;
			s='R';
		}
		else if(k%2==0&&k<=2*m)//当k是偶数且k在第一列的时候 
		{
			r=1;
		}
		else if(k%2!=0)//当k是奇数的情况 
		{
			r=k/(2*m)+1;
			s='L';
			d=(k%(2*m))/2+1;
		}
		if(k%(2*m)==0)//当k是列数的最后一个的时候  
		{
			d=m;
		}
		else if(k%(2*m)!=0&&k%2==0)//k是列数的最后一个的时候且当k是偶数的时候 
		{
			d=(k%(2*m))/2;
		}
		cout<<r<<" "<<d<<" "<<s<<endl;//输出r,f,s; 
	}
	return 0;
} 

 

相关标签: acm