博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cf 1B. Spreadsheets
阅读量:7086 次
发布时间:2019-06-28

本文共 2209 字,大约阅读时间需要 7 分钟。

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
2R23C55BC23
Output

BC23R23C55

//太恶心了,这转换到吐血#include
#include
#include
#include
using namespace std;#define N 10010char s[N];void to(int k){ stack
p; while(k){ p.push(k%26);k/=26; }; int i,l=0; while(!p.empty()){ //cout<
<
0;i--){ s[i]+=k; if(s[i]<'A'){ s[i]=s[i]+26;k=-1; }else k=0; } i=0; if(k==-1){ if(s[0]=='A')i=1; else s[0]--; } printf("%s",s+i);}void fun(int k){//R123C123 int x=0,y=0,i; for(i=1;i
='0'&&s[1]<='9'){ for(i=2;s[i];i++) if(s[i]=='C'){fun(i);i=-1;break;} } //ABC123 if(i!=-1){ int x=0,y=0; for(i=0;s[i]<='Z'&&s[i]>='A';i++){ x=x*26+(s[i]-'A'+1); } for(;s[i];i++)y=y*10+s[i]-'0'; printf("R%dC%d\n",y,x); } }return 0;}

 

 

 

转载地址:http://zrrml.baihongyu.com/

你可能感兴趣的文章
flask+sqlite3+echarts2+ajax数据可视化--静态图
查看>>
<十八>UML核心视图动态视图之协作图
查看>>
MERGE开发中遇到的问题
查看>>
独家 | 一文读懂LinkedIn个性化推荐模型及建模原理
查看>>
大数据时代CIO们必备的五大硬功
查看>>
近20天学习计划的完成情况
查看>>
[20150604]关于IOPS.txt
查看>>
原来Oracle也不喜欢“蜀黍”
查看>>
Eclipse:The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path
查看>>
【AI版狄仁杰】爱丁堡大学团队教AI识别犯罪剧中的罪犯,正确率达60%仍不及人类...
查看>>
JAVA线程的三种简单实现
查看>>
PV(访问量)、UV(独立访客)、IP(独立IP) (转)
查看>>
linux命令之scp
查看>>
查看 MySQL 用户权限
查看>>
统一预付费ECS资源到期日
查看>>
Nature:美国军方资助科研项目,AI植入大脑治疗心理疾病
查看>>
使用Iterator遍历Sheet(POI)验证及解释结果有序性
查看>>
HttpContext.Current.Cache 过期时间
查看>>
提问的智慧
查看>>
AIX平台上11.2 Grid Infrastructure RDBMS进程的user是grid用户?
查看>>