Spreadsheets
Time Limit:10000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
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
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的更多相关文章
- cf------(round)#1 B. Spreadsheets(模拟)
B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...
- CF Spreadsheets (数学)
Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard input ...
- codeforces 1B Spreadsheets
In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is u ...
- Codeforces Beta Round #1 B. Spreadsheets 模拟
B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular sprea ...
- B. Spreadsheets(进制转换,数学)
B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...
- C#-使用GoogleAPI读写spreadsheets
https://docs.google.com/spreadsheets/在线使用一些常用办公工具,比如excel. 如需要C#代码自动读写这些excel,则需要使用GoogleAPI. 封装的公用类 ...
- CF1B.Spreadsheets(电子表格) 题解 模拟
作者:zifeiy 标签:模拟 题目出处:Spreadsheets 题目描述 在流行的电子表格系统中(例如,在Excel中),使用如下计算方式来对列号进行计算. 第1列对应A,第2列对应B,--,第2 ...
- 【题解】codeforces 1B Spreadsheets
题意翻译 人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:第一列被标为A,第二列为B,以此类推,第26列为Z.接下来为由两个字母构成的列号: 第27列为AA,第28列为AB-在标为 ...
- CodeForces 1B Spreadsheets (字符串处理,注意细节,大胆尝试)
题目 注意模后余数为0时,要把除以26后的新数据减1,为什么这样,要靠大胆尝试.我在对小比赛中坑了一下午啊,直到比赛结束也没写出这道题....要死了.. #include<stdio.h> ...
随机推荐
- 在SSIS包中使用 Checkpoint从失败处重新启动包
使用SSIS做ETL的过程中会遇到各种各样的错误,对于一些大数据量的Job失败以后我们不希望重新运行,因为重新运行的时间开销是非常大的,我们只希望从失败的部分开始运行,这样可以省去很多的时间. SSI ...
- git将本地项目添加到github远程仓库
1.首先准备好你的github 账号密码,注册就不说了.. 2.由于本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以要在本地生成一个私钥和一个密钥 命令: $ ssh-keygen ...
- sql表连接的几种方式
这里有两张表TableA和TableB,分别是姓名表和年龄表,用于我们例子的测试数据 TableA id name 1 t1 2 t2 4 t4 TableB id age 1 18 2 20 3 1 ...
- 解决iOS7中UITableView在使用autolayout时layoutSubviews方法导致的crash
近期公司项目上线后,出现了大量的crash,发生在iOS7系统上,和UITableView相关: Auto Layout still required after executing -layoutS ...
- BZOJ 1050 旅行comf
题目如下: 题目描述 给你一个无向图,N(N<=500)个顶点, M(M<=5000)条边,每条边有一个权值Vi(Vi<30000).给你两个顶点S和T,求一条路径,使得路径上最大边 ...
- 关于playframework2.5
加入了很多新东西: 1.用akka streams 替换了大部分 iteratee-based async io,当然还有一些模块在用iteratees 2.java 的一些API 做了调整升级,以及 ...
- windows 下提取目录下所有文件的文件名
tree D:/dir /f >D:/filenames.txt 提取D盘dir目录下所有文件名,写入文件filenames.txt
- elasticsearch-5.0.0初见
基础概念 Elasticsearch有几个核心概念.从一开始理解这些概念会对整个学习过程有莫大的帮助. 接近实时(NRT) Elasticsearch是一个接近实时的搜索平台.这意味着,从索引一个文档 ...
- FASTCGI程序,做个备份,以后用
11FastCGI 用来作为 Web 服务器的设计方案,有着很多优点.要搭建这样一个服务,有一个最简单的办法来搭建,可以使用 Apache 以及 mod_fcgid 模块来实现. 鉴于网上有关 Fas ...
- c语言各类问题 代码
定义一个结构体,有两个成员变量,一个整型的n,一个字符型的c,利用结构体类型声明一个具有5个元素的数组,并随机初始化,根据成员变量n进行从小到大排序,然后输出 冒泡排序然后 在输出结构体#includ ...