博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Beta Round #1 B. Spreadsheets 模拟
阅读量:6974 次
发布时间:2019-06-27

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

B. Spreadsheets

题目连接:

Description

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 Input

2

R23C55
BC23

Sample Output

BC23

R23C55

Hint

题意

表格有两种表示方法,第一种

比如R23C55,就表示第23行,55列

第二种:

比如BC23,就表示在第BC列,23行,BC是一个26进制数,A是1,Z是26,BC就表示55=2*26+3

然后给你其中一种,让你转化成另外一种

题解:

模拟题,瞎跑跑就好了……

简单模拟题,进制转换,直接看(这个数-1)%26就好了。

代码

#include
using namespace std;string s;void solve1(){ int R=0,C=0; int flag = 0; for(int i=1;i
='0'&&flag==0) { flag = 1; cout<<"R"; } if(flag==1)cout<
>s; int flag1=0,flag2=0,flag3=0; for(int i=0;i
='A') flag3++; } if(s[0]=='R'&&s[1]=='C')flag1=0; if(flag3==2&&flag1&&flag2) solve1(); else solve2(); }}

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

你可能感兴趣的文章
Django学习(二) Django框架简单搭建
查看>>
“一票易得” 微微网络电话五一抢票进行时
查看>>
MySQL使用可重复读作为默认隔离级别的原因
查看>>
【工具使用系列】关于 MATLAB 径向基神经网络,你需要知道的事
查看>>
让我们一起Go(十一)
查看>>
关于USB数据存储这一块的技术问题
查看>>
创建第一个Azure Liunx虚拟机
查看>>
unstrict模式
查看>>
提高red5性能几个配置。
查看>>
tab键技巧小结
查看>>
数据库管理中文件的使用
查看>>
计算机英语单词汇总
查看>>
TCP、UDP和HTTP详解
查看>>
MYSQL数据库设计规范与原则
查看>>
chrome贴吧插件——源代码
查看>>
201621123048《Java程序设计》第六周学习总结
查看>>
Eclipse快捷键大全(转载)
查看>>
python压缩文件脚本
查看>>
把Catalina的字符串格式转化为日期格式
查看>>
【语法】NSMutableString的用法
查看>>