Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) A
Description
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.

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!
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.
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.
4 3 9
2 2 L
4 3 24
4 3 R
2 4 4
1 2 R
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.
题意:告诉我们座位的排序方式,让我们找出k号是几行几列,是左还是右
解法:数学计算(奇数偶数为L,R,列可以通过k/x求出,行这里我先计算(y-1)有多少个数字,再调整)
#include<bits/stdc++.h> using namespace std; #define ll long long int n,m,k; int a[10000]; int x,y; int t; int main() { cin>>n>>m>>k; x=m*2; if(k%x==0) { y=k/x; } else { y=k/x+1; } if(k%2==0) { if(y==1) { cout<<y<<" "<<(k+1)/2<<" "<<"R"<<endl; } else { cout<<y<<" "<<(k-(y-1)*2*m+1)/2<<" "<<"R"<<endl; } } else { if(y==1) { cout<<y<<" "<<(k+1)/2<<" "<<"L"<<endl; } else { cout<<y<<" "<<(k-(y-1)*2*m+1)/2<<" "<<"L"<<endl; } } return 0; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
2015-12-25 2015苏州大学ACM-ICPC集训队选拔赛(1) 1008
2015-12-25 2015苏州大学ACM-ICPC集训队选拔赛(1) 1007
2015-12-25 2015苏州大学ACM-ICPC集训队选拔赛(1) 1006
2015-12-25 2015苏州大学ACM-ICPC集训队选拔赛(1) 1005
2015-12-25 2015苏州大学ACM-ICPC集训队选拔赛(1) 1001 1002 1010