【codeforces 752A】Santa Claus and a Place in a Class

time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
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 m 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 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.

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 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.

【题目链接】:http://codeforces.com/contest/752/problem/A

【题解】

看一下第k个位置在第几列;
确定列之后、再确定行、然后再确定左边还是右边
按顺序来,不会有问题的;

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

//const int MAXN = x;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);

int n,m,k;

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    rei(n);rei(m);rei(k);
    int r = ((k-1)/(2*m))+1;
    int d;
    d = k-((k-1)/(2*m))*2*m;
    int temp = ((d-1)/2);
    printf("%d %d ",r,temp+1);
    temp = d - (temp)*2;
    if (temp==1)
        putchar('L');
    else
        putchar('R');
    puts("");
    return 0;
}

转载于:https://www.cnblogs.com/AWCXV/p/7626770.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值