codeforces 1B Spreadsheets
In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc.
The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23.
Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example.
Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system.
Input
The first line of the input contains integer number n (1 ≤ n ≤ 105), the number of coordinates in the test. Then there follow n lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 106 .
Output
Write n lines, each line should contain a cell coordinates in the other numeration system.
Example
2
R23C55
BC23
BC23
R23C55 解题思路:
题目意思很简单,就是变换两种表达方式,题目很水。。 实现代码:
#include<bits/stdc++.h>
using namespace std; int main()
{
int m,i;
string s;
char s1[];
cin>>m;
while(m--){
cin>>s;
int num = ;
for(i=;i<s.size()-;i++){
if(s[i]<='Z'&&s[i]>='A'&&s[i+]>=''&&s[i+]<='')
num++;
}
if(num == ){
int r = ,c = ;
for(i=;i<s.size();i++){
if(s[i]>=''&&s[i]<=''){
r = r* + s[i] - '';
}
if(s[i]<='Z'&&s[i]>='A'){
c = c* + s[i] - 'A'+;
//cout<<"c"<<c<<endl;
}
}
cout<<"R"<<r<<"C"<<c<<endl;
}
else{
int flag = ,r = ;
for(i=;i<s.size();i++){
if(s[i]=='C') {flag = i;break;}
}
for(i=flag + ;i<s.size();i++){
r = r* + s[i] - '';
}
//cout<<"r"<<r<<endl;
int k =;
while(r){
if(r%==){ //特殊情况当s[i] = Z 的时候,%26 = 0,不符合式子,而且此时 r/26 必须减一,具体为什么自己带两个数据推下就知道。
s1[k++] = 'Z';
r=r/-;}
else{
s1[k++] = 'A' + r%-;
r/=;}
}
for(i=k-;i>=;i--)
cout<<s1[i];
for(i=;i<flag;i++)
cout<<s[i];
cout<<endl;
}
}
return ;
}
codeforces 1B Spreadsheets的更多相关文章
- 【题解】codeforces 1B Spreadsheets
题意翻译 人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:第一列被标为A,第二列为B,以此类推,第26列为Z.接下来为由两个字母构成的列号: 第27列为AA,第28列为AB-在标为 ...
- CodeForces 1B Spreadsheets (字符串处理,注意细节,大胆尝试)
题目 注意模后余数为0时,要把除以26后的新数据减1,为什么这样,要靠大胆尝试.我在对小比赛中坑了一下午啊,直到比赛结束也没写出这道题....要死了.. #include<stdio.h> ...
- CodeForces 1B 模拟题。
H - 8 Time Limit:10000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- 【Codeforces 1B】Spreadsheets
[链接] 我是链接,点我呀:) [题意] A~Z分别对应了1~26 AA是27依次类推 让你完成双向的转换 [题解] 转换方法说实话特别恶心>_< int转string 得像数位DP一样一 ...
- 1B. Spreadsheets
题目大意: 行和列的两种方式. A是1, B是2,....Z是26, AA是27, AB是28........... 如: BC23代表55列23行 还有一种表示方法:R23C55, 代表23行,55 ...
- codeforces 1B 模拟
题目大意: 给出两种行列位置的表示方法,一个是Excel表示法,一个是(R,C)坐标表示.给出一种表示,输出另外一种表示. 基本思路: 模拟,首先判断是哪一种表示法,然后转换成另外一种表示方法: 我做 ...
- Codeforces Beta Round #1 B. Spreadsheets 模拟
B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular sprea ...
- Codeforces Beta Round #1 A,B,C
A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard in ...
- Codeforces 375C Circling Round Treasures - 最短路 - 射线法 - 位运算
You have a map as a rectangle table. Each cell of the table is either an obstacle, or a treasure wit ...
随机推荐
- Luogu4156 WC2016 论战捆竹竿 KMP、同余类最短路、背包、单调队列
传送门 豪华升级版同余类最短路-- 官方题解 主要写几个小trick: \(1.O(nm)\)实现同余类最短路: 设某一条边长度为\(x\),那么我们选择一个点,在同余类上不断跳\(x\),可以形成一 ...
- 51Nod 1677 treecnt
一道比较基础的计数题,还是一个常用的单独计算贡献的例子. 首先看题目和范围,暴力枚举肯定是不可行的,而且\(O(n\ logn)\)的算法貌似很难写. 那我们就来想\(O(n)\)的吧,我们单独考虑每 ...
- [Python]Practice makes perfect
Practice makes perfect 发音被儿子鄙视了.需要加强练习 以此自勉.
- Elasticsearch5.5.1插件开发指南
Elasticsearch5.5.1插件开发指南 原文地址: https://www.elastic.co/guide/en/elasticsearch/plugins/5.5/plugin-auth ...
- browserify运行原理分析
目前对于前端工程师而言,如果只针对浏览器编写代码,那么很简单,只需要在页面的script脚本中引入所用js就可以了. 但是某些情况下,我们可能需要在服务端也跑一套类似的逻辑代码,考虑如下这些情景(以n ...
- YY:2018互联网创业公司应看清的事情
潮流,技术,生活方式,盈利模式,消费人群几乎每年都在改变,2018,你看到的是怎样的一盘棋. 2018年是个很好的数字,很多互联网公司寄予希望在这个幸运数字年头奋起一搏,拿到一份可观的酬金.特别是一些 ...
- SCRUM 12.22
周一,大家现在课程也比较少,今天都在非常努力地写代码. 任务分配如往常一样,我们现在基本将工作的重心放在完善已有的组件上. 成员 任务 彭林江 落实API 牛强 落实意见反馈功能测试 高雅智 测试已完 ...
- 《Linux内核设计与分析》第六周读书笔记——第三章
<Linux内核设计与实现>第六周读书笔记——第三章 20135301张忻估算学习时间:共2.5小时读书:2.0代码:0作业:0博客:0.5实际学习时间:共3.0小时读书:2.0代码:0作 ...
- jiedui
源代码:https://github.com/hanzhaoyan/jieduizuoye/tree/master 功能要求: 该程序用图形界面实现下面功能:用计算机产生一个100以内的随机数,游戏者 ...
- 请求数据传入(SpringMVC)
1. 请求处理方法签名 Spring MVC 通过分析处理方法的签名,HTTP请求信息绑定到处理方法的相应人参中. Spring MVC 对控制器处理方法签名的限制是很宽松的,几乎可以按喜欢的任 ...