很水的一道题,提醒自己要认真,做的头都快晕了。考虑26的特殊情况。
D - Spreadsheets

Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Submit Status

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

Input
2
R23C55
BC23
Output
BC23
R23C55
 #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
using namespace std;
const int maxn=;
char str[maxn];
int num[maxn];
void print(int n)
{
if(n==)
printf("A");
if(n==)
printf("B");
if(n==)
printf("C");
if(n==)
printf("D");
if(n==)
printf("E");
if(n==)
printf("F");
if(n==)
printf("G");
if(n==)
printf("H");
if(n==)
printf("I");
if(n==)
printf("J");
if(n==)
printf("K");
if(n==)
printf("L");
if(n==)
printf("M");
if(n==)
printf("N");
if(n==)
printf("O");
if(n==)
printf("P");
if(n==)
printf("Q");
if(n==)
printf("R");
if(n==)
printf("S");
if(n==)
printf("T");
if(n==)
printf("U");
if(n==)
printf("V");
if(n==)
printf("W");
if(n==)
printf("X");
if(n==)
printf("Y");
if(n==||n<=)
printf("Z"); }
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int q=;
scanf("%s",str);
int len=strlen(str);
int flag=;
int ok=;
int sum=;
int temp=;
int temp2=;
for(int i=; i<len; i++)
{
if(flag==&&isalpha(str[i])==)
{
flag=;
temp2=i;
}
if(flag==&&isalpha(str[i])!=)
{
ok=;
temp=i;
break;
}
}
if(ok)
{
int p=;
for(int i=len-; i>temp; i--)
{
sum+=(str[i]-'')*p;
p*=;
}
// if(sum%26==0) 考虑错了
// {
// while(sum>0)
// {
// num[q++]=sum%26-1;
// if(sum==26)
// break;
// sum/=26;
// }
// }
// else while(sum>)
{
if(sum%==)
{
num[q++]=;
sum=sum/-;
}
else{
num[q++]=sum%;
sum/=;
}
}
for(int i=q-; i>=; i--)
{
// printf("%d ",num[i]);
print(num[i]);
}
for(int i=; i<temp; i++)
printf("%c",str[i]);
}
else
{
printf("R");
for(int i=temp2; i<len; i++)
printf("%c",str[i]);
printf("C");
int p=;
for(int i=temp2-; i>=; i--)
{
sum+=(str[i]-'A'+)*p;
p*=;
}
printf("%d",sum);
}
printf("\n");
}
}
 

Spreadsheets的更多相关文章

  1. cf------(round)#1 B. Spreadsheets(模拟)

    B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...

  2. CF Spreadsheets (数学)

    Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard input ...

  3. codeforces 1B Spreadsheets

    In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is u ...

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

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

  5. B. Spreadsheets(进制转换,数学)

    B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...

  6. C#-使用GoogleAPI读写spreadsheets

    https://docs.google.com/spreadsheets/在线使用一些常用办公工具,比如excel. 如需要C#代码自动读写这些excel,则需要使用GoogleAPI. 封装的公用类 ...

  7. CF1B.Spreadsheets(电子表格) 题解 模拟

    作者:zifeiy 标签:模拟 题目出处:Spreadsheets 题目描述 在流行的电子表格系统中(例如,在Excel中),使用如下计算方式来对列号进行计算. 第1列对应A,第2列对应B,--,第2 ...

  8. 【题解】codeforces 1B Spreadsheets

    题意翻译 人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:第一列被标为A,第二列为B,以此类推,第26列为Z.接下来为由两个字母构成的列号: 第27列为AA,第28列为AB-在标为 ...

  9. CodeForces 1B Spreadsheets (字符串处理,注意细节,大胆尝试)

    题目 注意模后余数为0时,要把除以26后的新数据减1,为什么这样,要靠大胆尝试.我在对小比赛中坑了一下午啊,直到比赛结束也没写出这道题....要死了.. #include<stdio.h> ...

随机推荐

  1. border-radius 知识点

    border-radius:50px; 边框半径 CSS度量值都:em.px.百分比如果设置1个值,表示4个圆角都使用这个值.如果设置两个值,表示左上角和右下角使用第一个值,右上角和左下角使用第二个值 ...

  2. 最近adt升级引起的问题

    其实也不知道是什么原因引起的,因为 之前安装的adt就是23.0.3的版本,但是最近突然创建安卓工程时出现了如下问题 D:\workspace\appcompat_v7\res\values-v21\ ...

  3. 移动端纯原生JS不依赖ajax后台服务器实现省市县三级联动

    最近好多天没有更新文章,是因为公司的项目忙的不行.今天有点时间,就突然想起在移动端项目中遇到三级联动的问题,网上查了很多资料,都是依赖各种插件,或者晦涩难于理解.于是,自己决定写一个出来. 当然,没有 ...

  4. C++中头文件(.h)和源文件(.cpp)都应该写些什么

    头文件(.h): 写类的声明(包括类里面的成员和方法的声明).函数原型.#define常数等,但一般来说不写出具体的实现. 在写头文件时需要注意,在开头和结尾处必须按照如下样式加上预编译语句(如下): ...

  5. 深入理解C/C++数组和指针

    C语言中数组和指针是一种很特别的关系,首先本质上肯定是不同的,本文从各个角度论述数组和指针. 一.数组与指针的关系数组和指针是两种不同的类型,数组具有确定数量的元素,而指针只是一个标量值.数组可以在某 ...

  6. JS学习之闭包的理解

    一.变量的作用域 要理解闭包,首先必须理解Javascript特殊的变量作用域.变量的作用域无非就是两种:全局变量和局部变量.Javascript语言的特殊之处,就在于函数内部可以直接读取全局变量.另 ...

  7. iptables 简单配置

    通过命令 netstat -tnl 可以查看当前服务器打开了哪些端口  Ssh代码   netstat -tnl     查看防火墙设置  Ssh代码   iptables -L -n      开放 ...

  8. jquery的extend()函数

    extend()是在写插件的过程中常用的方法,该方法有一些重载原型. 1.该方法的原型是: extend(dest,src1,src2,src3...); 它的含义是将src1,src2,src3.. ...

  9. win7 64位 TortoiseSVN-1.8.4客户端安装

    下载地址链接:http://pan.baidu.com/s/1nukeBVz 密码:tc79 (32 64位都有,注意区分) next一路安装 安装好后,在需要和服务器同步的文件夹图标上--鼠标右键- ...

  10. PHP-语法(www.w3school.com.cn/php)

    写在前面: 假设系统里已安装PHP软件 PHP是一种脚本语言,执行PHP脚本后向浏览器返回纯HTML语言(即后台将.php文件的执行结果以纯HTML的形式返回到前端) ---------------- ...