cf------(round)#1 B. Spreadsheets(模拟)
10 seconds
64 megabytes
standard input
standard output
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.
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 .
Write n lines, each line should contain a cell coordinates in the other numeration system.
2
R23C55
BC23
BC23
R23C55 代码:
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
int n,i;
char str[];
bool flag;
//freopen("test.in","r",stdin);
//freopen("test.out","w",stdout);
scanf("%d",&n);
while(n--){
scanf("%s",str);
flag=true;
int len=strlen(str);
if(str[]>=''&&str[]<=''){
for(i=;i<len;i++){
if(str[i]>='A'&&str[i]<='Z'){
//说明是第二种格式r--c--
char ss[]="\0";
strncpy(ss,str+,i-);
//printf("%s%s\n",str+i+1,ss);
//先转化为整数
int ans=;
int t=;
i++;
while((len--)>i){
ans+=((int)(str[len]-''))*t;
t*=;
}
i=;
int st[]={};
while(ans>){
//temp=work(i);
if(ans%==){
if(ans>=)st[i++]=;
else st[i++]=ans;
ans/=;
ans--;
}
else{
st[i++]=ans%;
ans/=;
}
}
for(--i;i>=;i--){
if(st[i]) putchar((st[i]-+'A'));
else putchar('Z');
}
printf("%s\n",ss);
flag=false;
break;
}
}
}
//第一种格式
if(flag) {
char ss[]="\0";
int k=;
for( i=;i<len;i++){
if(str[i]>='A'&&str[i]<='Z')
ss[k++]=str[i];
else break;
}
printf("R%sC",str+i);
int ans=,t=;
while(k--){
ans+=((int)(ss[k]-'A')+)*t;
t*=;
}
printf("%d\n",ans);
}
}
return ;
}
cf------(round)#1 B. Spreadsheets(模拟)的更多相关文章
- Codeforces Beta Round #1 B. Spreadsheets 模拟
B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular sprea ...
- CF Round #600 (Div 2) 解题报告(A~E)
CF Round #600 (Div 2) 解题报告(A~E) A:Single Push 采用差分的思想,让\(b-a=c\),然后观察\(c\)序列是不是一个满足要求的序列 #include< ...
- CF round #622 (div2)
CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...
- CF Round #551 (Div. 2) D
CF Round #551 (Div. 2) D 链接 https://codeforces.com/contest/1153/problem/D 思路 不考虑赋值和贪心,考虑排名. 设\(dp_i\ ...
- CF Round #510 (Div. 2)
前言:没想到那么快就打了第二场,题目难度比CF Round #509 (Div. 2)这场要难些,不过我依旧菜,这场更是被\(D\)题卡了,最后\(C\)题都来不及敲了..最后才\(A\)了\(3\) ...
- UOJ #30. [CF Round #278] Tourists
UOJ #30. [CF Round #278] Tourists 题目大意 : 有一张 \(n\) 个点, \(m\) 条边的无向图,每一个点有一个点权 \(a_i\) ,你需要支持两种操作,第一种 ...
- 竞赛题解 - CF Round #524 Div.2
CF Round #524 Div.2 - 竞赛题解 不容易CF有一场下午的比赛,开心的和一个神犇一起报了名 被虐爆--前两题水过去,第三题卡了好久,第四题毫无头绪QwQ Codeforces 传送门 ...
- 【前行&赛时总结】◇第4站&赛时9◇ CF Round 513 Div1+Div2
◇第4站&赛时9◇ CF Round 513 Div1+Div2 第一次在CF里涨Rating QWQ 深感不易……作blog以记之 ( ̄▽ ̄)" +Codeforces 的门为你打 ...
- CF Round #580(div2)题解报告
CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然 ...
- 【codeforces】【比赛题解】#915 Educational CF Round 36
虽然最近打了很多场CF,也涨了很多分,但是好久没写CF的题解了. 前几次刚刚紫名的CF,太伤感情了,一下子就掉下来了,不懂你们Div.1. 珂学的那场我只做了第一题……悲伤. 这次的Education ...
随机推荐
- js 定位到某个锚点
js 定位到某个锚点 html页面内可以设置锚点,锚点定义 <a name="firstAnchor">&nsbp;</a> 锚点使用 <a ...
- [SAP ABAP开发技术总结]消息处理Messages
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- CA*Layer(CAReplicatorLayer--)
CAReplicatorLayer (反射应用) 指定一个继承于UIView的ReflectionView,它会自动产生内容的反射效果: + (Class)layerClass//我们也可以通过重写V ...
- 【CC评网】2013.第41周 不求排版,简单就好
书单 碰上国庆,加上这周,消化掉几本书: <软件随想录>:Joel的随想录,也就是他Blog上的文章的摘选:整本书看下来轻松:写了篇读书笔记[传送门]: <中国在梁庄>:这本书 ...
- NoSql存储日志数据之Spring+Logback+Hbase深度集成
NoSql存储日志数据之Spring+Logback+Hbase深度集成 关键词:nosql, spring logback, logback hbase appender 技术框架:spring-d ...
- Simulating a Freight robot in Gazebo
Installation Before installing the simulation environment, make sure your desktop is setup with a st ...
- 数据库mysql中distinct关键词
在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值.关键词 distinct用于返回唯一不同的值. 例如,在学生信息表中,你想查询该学校有多少个系.例如, ...
- pfx,cer转pem,并对通过pem文件进行签名与验签
因为PHP无法读取.pfx文件,所以可以先转换为.pem文件然后在读取里面的数据,可以读取.cer文件,为了两方面统一,就都换成.pem然后再进行加签和验签. sign.php <?php de ...
- mysql概要(三)having
1.运算符 2.模糊查询 3.where 后的判断基于表(表的直接内容),而不是基于结果(运算之后的别名)如: 可改成在where后再次重新计算判断: 或者使用having对结果判断: having多 ...
- mysql 1030 Got error 28 from storage engine
mysql 1030 Got error 28 from storage engine 错误原因:磁盘临时空间不够. 解决办法:df -h 查看设备存储的使用情况 du -h --max-depth= ...