zoukankan      html  css  js  c++  java
  • 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 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.

    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 <iostream>
    
    using namespace std;
    
    int main() {
        int n, m, k;
        cin>>n>>m>>k; int h, l;
        int t;
        t = (k+1) / 2;
        //cout<<t<<endl;
        l = t / m;
        h = t % m;
        if(h !=0)
            l++;
        else if(h == 0)
        {
            h=m;
        }
        cout<<l<<" "<<h<<" ";
        if(k % 2 == 0)
            cout<<"R"<<endl;
        else cout<<"L"<<endl;
        return 0;
    }

     

  • 相关阅读:
    你有没有发现你的文章被人侵权?推荐一个工具给你
    带你找到五一最省的旅游路线【dijkstra算法代码实现】
    【最短路径Floyd算法详解推导过程】看完这篇,你还能不懂Floyd算法?还不会?
    Floyd算法java实现demo
    【销售系统设计01】关于线上与线下销售业绩冲突处理
    jenkins maven 自动远程发布到服务器,钉钉提醒团队
    研究windows下SVN备份及还原恢复方案
    xamarin.android SurfaceView 实现 游戏 触摸摇杆
    C++ 头文件和源文件 和 编译流程
    十大经典排序算法总结(JavaScript描述)
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6438766.html
Copyright © 2011-2022 走看看