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

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

1B. Spreadsheets

time limit :per test10 seconds

memory limit :per test64 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.

Examples

input
2
R23C55
BC23
output
BC23
R23C55

注意字符串与数字转化处

#include 
#include
using namespace std;int judge(string str){ int last_pos=0; for(int i=0;i
='A'&&str[i]<='Z') last_pos = i; } bool isnumber = false; for(int i=0;i<=last_pos ;i++){ if(str[i]<'A'||str[i]>'Z'){ isnumber = true; break; } } return isnumber?2:1;}string firstTosecond(string str){ // BC23->RXCY int col = 0,row = 0; int i; string res = "R"; for(i=0;str[i]>='A'&&str[i]<='Z';i++){ col = col*26+str[i]-'A'+1; } res+=str.substr(i); res+="C"; string temp_col; string begin = "0"; while(col){ string begin_temp = begin; int offset = col%10; begin_temp[0]=begin[0]+offset; temp_col=begin_temp+temp_col; col/=10; } res+=temp_col; return res;}string secondTofirst(string str){ //RXCY->BC23 string res; string row; int i; for(i=1;str[i]!='C';i++){ row+=str[i]; } int col=0; for(i++;i
>n; while(n--){ string str; cin>>str; if(judge(str)==1) cout<
<

转载于:https://www.cnblogs.com/GoFly/p/5751073.html

你可能感兴趣的文章
【Linux】echo命令
查看>>
MySQL主从1205报错【转】
查看>>
SpringBoot启动和停止脚步
查看>>
BZOJ1014: [JSOI2008]火星人prefix(splay 二分 hash)
查看>>
LWIP_STM32_ENC28J60(转)
查看>>
Visual Studio 2019 preview中体验C# 8.0新语法
查看>>
Linux下进程通信之管道
查看>>
CentOS 7创建自定义KVM模板(现有KVM迁移到另外一台机)
查看>>
Python异常处理详解
查看>>
Nginx服务状态的监控
查看>>
JDBC-ODBC桥接方法连接Excel数据库的方法
查看>>
使用WCF的Trace与Message Log功能
查看>>
电子书下载:Beginning iPhone 4 Development: Exploring the iOS SDK
查看>>
Qt的元对象(Meta-Object)系统简介
查看>>
matlab练习程序(最大似然估计)
查看>>
Oracle 各种查询语句
查看>>
工厂方法模式与IoC/DI
查看>>
Linux编程(获取系统时间)
查看>>
速记 - 实现sql server clr trigger
查看>>
PowerShell 开发
查看>>