B. Spreadsheets
time limit per test

10 seconds

memory limit per test

64 megabytes

input

standard input

output

standard output

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.

Sample test(s)
Input
2
R23C55
BC23
Output
BC23
R23C55 代码:
 #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
int n,i;
char str[];
bool flag;
//freopen("test.in","r",stdin);
//freopen("test.out","w",stdout);
scanf("%d",&n);
while(n--){
scanf("%s",str);
flag=true;
int len=strlen(str);
if(str[]>=''&&str[]<=''){
for(i=;i<len;i++){
if(str[i]>='A'&&str[i]<='Z'){
//说明是第二种格式r--c--
char ss[]="\0";
strncpy(ss,str+,i-);
//printf("%s%s\n",str+i+1,ss);
//先转化为整数
int ans=;
int t=;
i++;
while((len--)>i){
ans+=((int)(str[len]-''))*t;
t*=;
}
i=;
int st[]={};
while(ans>){
//temp=work(i);
if(ans%==){
if(ans>=)st[i++]=;
else st[i++]=ans;
ans/=;
ans--;
}
else{
st[i++]=ans%;
ans/=;
}
}
for(--i;i>=;i--){
if(st[i]) putchar((st[i]-+'A'));
else putchar('Z');
}
printf("%s\n",ss);
flag=false;
break;
}
}
}
//第一种格式
if(flag) {
char ss[]="\0";
int k=;
for( i=;i<len;i++){
if(str[i]>='A'&&str[i]<='Z')
ss[k++]=str[i];
else break;
}
printf("R%sC",str+i);
int ans=,t=;
while(k--){
ans+=((int)(ss[k]-'A')+)*t;
t*=;
}
printf("%d\n",ans);
}
}
return ;
}

cf------(round)#1 B. Spreadsheets(模拟)的更多相关文章

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

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

  2. CF Round #600 (Div 2) 解题报告(A~E)

    CF Round #600 (Div 2) 解题报告(A~E) A:Single Push 采用差分的思想,让\(b-a=c\),然后观察\(c\)序列是不是一个满足要求的序列 #include< ...

  3. CF round #622 (div2)

    CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...

  4. CF Round #551 (Div. 2) D

    CF Round #551 (Div. 2) D 链接 https://codeforces.com/contest/1153/problem/D 思路 不考虑赋值和贪心,考虑排名. 设\(dp_i\ ...

  5. CF Round #510 (Div. 2)

    前言:没想到那么快就打了第二场,题目难度比CF Round #509 (Div. 2)这场要难些,不过我依旧菜,这场更是被\(D\)题卡了,最后\(C\)题都来不及敲了..最后才\(A\)了\(3\) ...

  6. UOJ #30. [CF Round #278] Tourists

    UOJ #30. [CF Round #278] Tourists 题目大意 : 有一张 \(n\) 个点, \(m\) 条边的无向图,每一个点有一个点权 \(a_i\) ,你需要支持两种操作,第一种 ...

  7. 竞赛题解 - CF Round #524 Div.2

    CF Round #524 Div.2 - 竞赛题解 不容易CF有一场下午的比赛,开心的和一个神犇一起报了名 被虐爆--前两题水过去,第三题卡了好久,第四题毫无头绪QwQ Codeforces 传送门 ...

  8. 【前行&赛时总结】◇第4站&赛时9◇ CF Round 513 Div1+Div2

    ◇第4站&赛时9◇ CF Round 513 Div1+Div2 第一次在CF里涨Rating QWQ 深感不易……作blog以记之 ( ̄▽ ̄)" +Codeforces 的门为你打 ...

  9. CF Round #580(div2)题解报告

    CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然 ...

  10. 【codeforces】【比赛题解】#915 Educational CF Round 36

    虽然最近打了很多场CF,也涨了很多分,但是好久没写CF的题解了. 前几次刚刚紫名的CF,太伤感情了,一下子就掉下来了,不懂你们Div.1. 珂学的那场我只做了第一题……悲伤. 这次的Education ...

随机推荐

  1. 关于cookie的清除

    关于cookie的清除     设置cookie时若指定了目录,那么在删除cookie时也必须指定相同的目录,如此才可以删除之前设置的cookie的值!!!!!!!!!

  2. git push 403

    1. 在github上新建一个空项目. 2. git clone 到本地仓库. 3. git add [一些文件]. 4. git commit -m "first commit" ...

  3. V-rep学习笔记:机器人逆运动学数值解法(The Pseudo Inverse Method)

    There are two ways of using the Jacobian matrix to solve kinematics. One is to use the transpose of ...

  4. Creating Dynamic LOV in Oracle D2k Forms

    Dynamic Lov is a good idea for the form where too many Lov requirement is there with different recor ...

  5. read 计时命令

    使用read命令存在潜在危险,脚本很可能会停下来一直等待脚本用户输入数据,如果无论是否输入数据脚本的必须继续执行,那么可以使用-t选项指定一个计时器.-t选项指定read命令等待输入的秒数,当计数器计 ...

  6. 使用ultramon调整任务栏高度

    取消锁定,调整任务栏的高度为一行图标的高度,然后再锁定即可.为啥程序没有默认设置?

  7. STRUTS2 嵌套循环

    <!--begin 类目循环 --> <s:iterator value="categories" id='i' begin="0" step ...

  8. C++中关于new及内存地址的思考

    OJ题刷多了,每次都是直接分配内存,那么,你还记得怎么动态分配内存吗? ———————————————————————————————————— 我们知道,使用malloc/calloc等分配内存的函 ...

  9. Java 多线程 (转)

    http://www.ibm.com/developerworks/cn/java/j-thread/index.html http://www.ibm.com/developerworks/cn/j ...

  10. Android 四种简单的动画(淡入淡出、旋转、移动、缩放效果)

    最近在Android开发当中,用到的动画效果. public void onClick(View arg0) { // TODO 自动生成的方法存根 switch (arg0.getId()) { c ...