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> ...
随机推荐
- OpenGL 4 : 一个漂亮的心 For you, My Love
画一个心形有非常多公式能够使用,以下这个公式我觉得最完美了: float x = R * 16 * pow(sin(theta), 3); float y = R * (13 * cos(theta) ...
- 对JAVA Bean使用PropertyDescriptor反射调用JAVA方法
对于符合JAVA Bean规范的bean,调用其方法应优先使用java.beans.PropertyDescriptor获取Method进行方法调用,以获得更大的可维护性. 示比例如以下: NonCo ...
- iOS app 集成友盟推送问题
之前做app推送主要是集成友盟SDK,在程序获取deviceToken时,老是提示如下错误: Error Domain=NSCocoaErrorDomain Code=3000 "未找到应用 ...
- SharePoint 2007 (MOSS/WSS) - how to remove "Download a Copy" context menu from a Document Library
One of my friend and colleague asked me this question. I found it tricky and a good post for my blog ...
- js页面loading加载
<html> <head> <title>页面正在载入</title> <script language=" ...
- 使用命令行将Excel数据表导入Mysql中的方法小结
从Excel数据表导入MySQL,已经做过好几次了,但每次都会碰到各种问题:invalid utf8 character string, data too long, ...,浪费了不少时间 为了提高 ...
- C++ STL中map存储方式——SAP电面(4)
map存储方式 一般是平衡二叉树 红黑树
- BZOJ 2329: [HNOI2011]括号修复( splay )
把括号序列后一定是))))((((这种形式的..所以维护一个最大前缀和l, 最大后缀和r就可以了..答案就是(l+1)/2+(r+1)/2...用splay维护,O(NlogN). 其实还是挺好写的, ...
- A Byte of Python 笔记(5)函数:定义、形参、局部变量、默认参数、关键参数
第7章 函数 函数是重要的程序段.它们允许你给一块语句一个名称,然后你可以在程序的任何地方使用这个名称任意多次地运行这个语句块.这被称为 调用 函数. 定义函数 函数通过 def 关键字定义.def ...
- IOS 警告框 (UIAlertView)的使用方法
1.普通警告框 IOS的SDK中提供了一个方便的类库UIAlertView,配合着不同参数来使用此类可以做出大多数的警告框,如下代码是IOS最简单的警告框. UIAlertView *alert = ...