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> ...
随机推荐
- 新手不得不注意HTML CSS 规范
作为一名新进的程序菜鸟,根本不知道从哪里开始学起好,前辈都说HTML CSS 规范是一个十分需要注意的点,要我记下,特地转来保存一下,大家相互学习 //总论 本规范既然一个开发规范,也是一个脚本语言参 ...
- IE7下浮动元素的内容自动换行的BUG解决方法
有时候我们想写个浮动得到这样的效果: 代码: <!doctype html> <html> <head> <meta charset="utf-8& ...
- iOS工程上传AppStore时遇到的问题“ERROR ITMS-90046”解析
在我们将代码写完整,测试没有bug之后,我们就可以将它上传到AppStore了,上传的过程只要操作正确并不会有太大的问题,但是打包的过程中会出现一些小问题,导致打的包不能上传或者上传的时候会出现错误. ...
- Map(关联式容器)
map是一类关联式容器,自动建立Key - Value的对应 , key 和 Value可以是任意你需要的类型.下面介绍 map 中一些常用的函数: 一.map 中的 begin 和 end 函数 m ...
- HTML5 实现图像模糊算法
做个广告,WEB/PHP/JQ/HTML5/MYSQL/QQ群6848027 项目中需要用到HTML5模糊图像,以前用GDI,GDI+中都有现成的组件来实现,HTML5中如何实现? createIma ...
- PHP PDO select语句结果行数计算
PDO有一个函数PDOStatement::rowCount返回上一个SQL语句影响的行数. rowCount函数对于DELETE, INSERT, 或者UPDATE语句的结果是正确的,但对于sele ...
- java 类排序
参考文档:Java排序: Comparator vs Comparable 入门 java类经常面临排序问题,据我所知:java提供comparable和comparator两种比较方式: 1. co ...
- Python collections.defaultdict 笔记
其实defaultdict 就是一个字典,只不过python自动的为它的键赋了一个初始值.这也就是说,你不显示的为字典的键赋初值python不会报错,看下实际例子. 比如你想计算频率 frequenc ...
- C单链表实现
/* * LinkNode.c * * Created on: Jan 14, 2014 * Author: root */ #include <stdlib.h> #include &l ...
- Qt官方开发环境生成的exe发布方式--使用windeployqt(windeployqt是单独的程序,放在低版本qt4目录下也可以运行的)
Qt 官方开发环境使用的动态链接库方式,在发布生成的exe程序时,需要复制一大堆 dll,如果自己去复制dll,很可能丢三落四,导致exe在别的电脑里无法正常运行.因此 Qt 官方开发环境里自带了一个 ...