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> ...
 
随机推荐
- Android仿人人客户端(v5.7.1)——个人主页(三)
			
转载请标明出处:http://blog.csdn.net/android_ls/article/details/9405089 声明:仿人人项目,所用所有图片资源都来源于其它Android移动应用,编 ...
 - linux进程之fork 和 exec函数
			
---恢复内容开始--- fork函数 该函数是unix中派生新进程的唯一方法. #include <unistd.h> pid_t fork(void); 返回: (调用它一次, 它 ...
 - Problem A Where is the Marble?(查找排序)
			
题目链接:Problem A 题意:有n块大理石,每个大理石上写着一个非负数,首先把数从小到大排序,接下来有Q个问题,每个问题是是否有某个大理石上写着x,如果有,则输出对应的大理石编号. 思路:先排序 ...
 - POJ 2689 Prime Distance(素数筛选)
			
题目链接:http://poj.org/problem?id=2689 题意:给出一个区间[L, R],找出区间内相连的,距离最近和距离最远的两个素数对.其中(1<=L<R<=2,1 ...
 - datatable,查询,排序,复制等操作
			
DataTable排序,检索,合并详解 一.排序 获取DataTable的默认视图 对视图设置排序表达式 用排序后的视图导出的新DataTable替换就DataTable (Asc升序可省略,多列排序 ...
 - php不同版本特性记录
			
最近在用php开发时项目中遇到了版本问题,特此记录下php不同版本的一些特性记录,以备忘. 一:php5.3中的新特性 1)开始支持命名空间(Namespace) 2)支持延迟静态绑定(Late St ...
 - 05-C语言运算符
			
目录: 一.进制转换 二.常量 三.sizeof 四.运算符 五.赋值运算符 六.自增减运算符 七.关系运算符 八.逻辑运算符 九.取址寻址运算符 回到顶部 一.进制转换 1 进制转换是人们利用符号来 ...
 - php命名空间及和autoload结合使用问题。
			
在讨论如何使用命名空间之前,必须了解 PHP 是如何知道要使用哪一个命名空间中的元素的.可以将 PHP 命名空间与文件系统作一个简单的类比.在文件系统中访问一个文件有三种方式: 相对文件名形式如foo ...
 - Windows Azure 网站 (WAWS) 中的服务器端包含 (SSI)
			
 编辑人员注释:本文章由 Windows Azure 网站团队的项目经理Erez Benari 撰写. Windows Azure 网站客户普遍关心的一个问题是关于我们对服务器端包含(Server ...
 - openScales源码学习系列之 Feature属性
			
coordinates:当前区域,geometry或Polygon的点集合. countries.国家所在位置下标 SQKM.平方千米 COLOR_MAP.该国家的颜色类别 SQMI.平方英里 CON ...