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. 【第196期】Drupal7 Features模块与 Drupal8 Configuration Management 模块对比

    Drupal 8 最好和最受欢迎的部分之一是新的配置管理系统. 该系统使开发人员很容易将配置导出到代码中.在此之前,开发人员不得不依赖于由Features.Strongarm.UUID.Feature ...

  2. Lua 中的条件表达式

    下面这代码段看上去很熟悉,就是C#里面的条件表达式,很多其它语言也都有这么一个条件表达式. ; ; string c = "c"; string d = "d" ...

  3. Luogu4886 快递员 点分治

    传送门 淀粉质好题啊qaq 我们先考虑随便选择一个点作为邮递中心,通过移动邮递中心找到更优的位置.将路径最大值求出,并将路径最大值对应的那一些路径拿出来考虑.可以知道,如果说这些路径中存在一条经过当前 ...

  4. CF809D Hitchhiking in the Baltic States LIS、平衡树

    传送门 看到最长上升子序列肯定是DP 设\(f_i\)表示计算到当前,长度为\(i\)的最长上升子序列的最后一项的最小值,显然\(f_i\)是一个单调递增的序列. 转移:对于当前计算的元素\(x\), ...

  5. C# 16进制转 Brush 颜色对象

    原文:C# 16进制转 Brush 颜色对象 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u014117094/article/details/4 ...

  6. [转][南京米联ZYNQ深入浅出]第二季更新完毕课程共计16节课

    [南京米联]ZYNQ第二季更新完毕课程共计16节课 [第二季ZYNQ]                                                                  ...

  7. ES7 之 Async/await 的使用

    在 js 异步请求数据时,通常,我们多采用回调函数的方式解决,但是,如果有多个回调函数嵌套时,代码显得很不优雅,维护成本也相应较高. ES6 提供的 Promise 方法和 ES7 提供的 Async ...

  8. Docker容器学习梳理 - SSH方式登陆容器

    前面几篇已经介绍了Docker基础环境的部署,下面介绍下通过ssh方式登陆Docker容器的操作记录(其实不太建议直接用ssh去连接上容器的想法,虽然可以,但是有很多弊端,而且docker已经提供了容 ...

  9. Fedora 19关闭防火墙

    关闭防火墙systemctl stop firewalld.service 关闭开机启动防火墙systemctl disable firewalld.service

  10. FormData

    1. 概述FormData类型其实是在XMLHttpRequest 2级定义的,它是为序列化表以及创建与表单格式相同的数据(当然是用于XHR传输)提供便利. 2. 构造函数创建一个formData对象 ...