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

Input
2
R23C55
BC23
Output
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的更多相关文章

  1. 【题解】codeforces 1B Spreadsheets

    题意翻译 人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:第一列被标为A,第二列为B,以此类推,第26列为Z.接下来为由两个字母构成的列号: 第27列为AA,第28列为AB-在标为 ...

  2. CodeForces 1B Spreadsheets (字符串处理,注意细节,大胆尝试)

    题目 注意模后余数为0时,要把除以26后的新数据减1,为什么这样,要靠大胆尝试.我在对小比赛中坑了一下午啊,直到比赛结束也没写出这道题....要死了.. #include<stdio.h> ...

  3. CodeForces 1B 模拟题。

    H - 8 Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  4. 【Codeforces 1B】Spreadsheets

    [链接] 我是链接,点我呀:) [题意] A~Z分别对应了1~26 AA是27依次类推 让你完成双向的转换 [题解] 转换方法说实话特别恶心>_< int转string 得像数位DP一样一 ...

  5. 1B. Spreadsheets

    题目大意: 行和列的两种方式. A是1, B是2,....Z是26, AA是27, AB是28........... 如: BC23代表55列23行 还有一种表示方法:R23C55, 代表23行,55 ...

  6. codeforces 1B 模拟

    题目大意: 给出两种行列位置的表示方法,一个是Excel表示法,一个是(R,C)坐标表示.给出一种表示,输出另外一种表示. 基本思路: 模拟,首先判断是哪一种表示法,然后转换成另外一种表示方法: 我做 ...

  7. Codeforces Beta Round #1 B. Spreadsheets 模拟

    B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular sprea ...

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

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

随机推荐

  1. 9-51单片机ESP8266学习-AT指令(单片机采集温湿度数据通过8266发送给AndroidTCP客户端显示)

    http://www.cnblogs.com/yangfengwu/p/8798512.html 补充:今天答应了一个朋友写一下如果单片机发过的是字符串应该怎么解析,答应了今天写,哦哦哦是明天了,闲话 ...

  2. Tensorflow-hub[例子解析1]

    0. 引言 Tensorflow于1.7之后推出了tensorflow hub,其是一个适合于迁移学习的部分,主要通过将tensorflow的训练好的模型进行模块划分,并可以再次加以利用.不过介于推出 ...

  3. Spring Boot 之属性读写详解

    SpringBoot 之属性读写详解 加载 property 顺序 随机属性 命令行属性 Application 属性文件 Profile 特定属性 属性中的占位符 YAML 属性 访问属性 多 pr ...

  4. UVA1626 - Brackets sequence(区间DP--括号匹配+递归打印)

    题目描写叙述: 定义合法的括号序列例如以下: 1 空序列是一个合法的序列 2 假设S是合法的序列.则(S)和[S]也是合法的序列 3 假设A和B是合法的序列.则AB也是合法的序列 比如:以下的都是合法 ...

  5. CF1101G (Zero XOR Subset)-less 线性基

    传送门 既然每一次选择出来的都是一个子段,不难想到前缀和计算(然而我没有想到--) 设异或前缀和为\(x_i\),假设我们选出来的子段为\([1,i_1],(i_1,i_2],...,(i_{k-1} ...

  6. React-异步组件及withRouter路由方法的使用

    所有组件的代码都打包在bundle.js里,加载首页的时候,把其它页面的代码也加载了,影响首页加载速度.我们希望访问首页的时候只加载首页,访问详情页的时候再去加载详情页的代码.异步组件可以帮我们实现, ...

  7. 重装系统之U盘设为第一启动项

    做好启动盘之后(教程:重装系统之制作U盘启动盘),接下来该设置U盘为第一启动项. 以我的电脑(华硕X450JN)为例,开机不停地按f2,进入系统引导界面. 其它牌子的电脑可以在开机时候试试esc,f1 ...

  8. 【APIO2016】烟火表演

    题面 题解 神仙题目啊QwQ 设\(f_i(x)\)表示以第\(i\)个点为根的子树需要\(x\)秒引爆的代价. 我们发现,这个函数是一个下凸的一次分段函数. 考虑这个函数合并到父亲节点时会发生怎样的 ...

  9. pandas:字段值插入数据表第一行的解决办法

    1. 问题描述 在对课程表进行数据抽取时,由于课表结构的原因,需要在原始表字段名作为第一行数据,并对原始字段名进行替换. 原始数据如下所示: 2. 解决办法 经思考,此问题可抽象为:在不影响原始数据的 ...

  10. 基于uFUN开发板的RGB调色板

    前言 使用uFUN开发板配合Qt上位机,实现任意颜色的混合,Qt上位机下发RGB数值,范围0-255,uFUN开发板进行解析,然后输出不同占空比的PWM,从而实现通过RGB三原色调制出任意颜色. Qt ...