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. libreoffice实现WORD文档转PDF文档

    一.安装LibreOffice 官网:http://www.libreoffice.org/ 二.CentOS安装yum yum install libreoffice 三.执行转换命令 libreo ...

  2. 个人简历制作(Dreamweaver)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. c#扩展方法的理解(一:初识)

    扩展方法是静态方法,是类的一部分,但是实际上没有放在类的源代码中. 扩展方法所在的类也必须被声明为static C#只支持扩展方法,不支持扩展属性.扩展事件等. 扩展方法的第一个参数是要扩展的类型,放 ...

  4. JAVA排序--[冒泡排序]

    package com.array; public class Sort_MaoPao { /** * 项目名称:冒泡排序 * 项目要求:用JAVA对数组进行排序,并运用冒泡排序算法 * 作者:Sev ...

  5. TCP的流量控制和拥塞控制

    1.TCP的流量控制 一般说来,我们总是希望数据传输的更快一些.但如果发送方吧数据发送的过快,接收方就可能来不及接收,就会造成数据的丢失.所谓的流量控制就是让发送方的发送速率不要太快,要让接收方来的及 ...

  6. Codeforces Round #249 (Div. 2) A题

    链接:http://codeforces.com/contest/435/problem/A   A. Queue on Bus Stop time limit per test 1 second m ...

  7. git bash下的选择、复制、粘贴

      1. 打开git bash     2.点击左上角,选择属性,打钩     3.回到界面,选择一行文字,然后点击 “右键”,这样就复制到剪切板了.再点 “右键”,可以粘贴到命令窗口中了.    

  8. ARC 下处理内存暴涨的一个解决办法

    有一种情况: ; i < ; i++) { NSString *s = @"ABC"; s = [s lowercaseString]; s = [s stringByApp ...

  9. Java 实现阶乘算法

    阶乘算法如下: 以下列出 0 至 20 的阶乘: 0!=1,(0 的阶乘是存在的) 1!=1, 2!=2, 3!=6, 4!=24, 5!=120, 6!=720, 7!=5040, 8!=40320 ...

  10. Maven测试

    生命周期阶段需要绑定到某个插件的目标才能完成真正的工作,test阶段正是与maven-surefire-plugin的test目标相绑定了,这是一个 内置的绑定. 在默认情况下,maven-suref ...