codeforces 1B Spreadsheets
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.
Example
2
R23C55
BC23
BC23
R23C55 解题思路:
题目意思很简单,就是变换两种表达方式,题目很水。。 实现代码:
#include<bits/stdc++.h>
using namespace std; int main()
{
int m,i;
string s;
char s1[];
cin>>m;
while(m--){
cin>>s;
int num = ;
for(i=;i<s.size()-;i++){
if(s[i]<='Z'&&s[i]>='A'&&s[i+]>=''&&s[i+]<='')
num++;
}
if(num == ){
int r = ,c = ;
for(i=;i<s.size();i++){
if(s[i]>=''&&s[i]<=''){
r = r* + s[i] - '';
}
if(s[i]<='Z'&&s[i]>='A'){
c = c* + s[i] - 'A'+;
//cout<<"c"<<c<<endl;
}
}
cout<<"R"<<r<<"C"<<c<<endl;
}
else{
int flag = ,r = ;
for(i=;i<s.size();i++){
if(s[i]=='C') {flag = i;break;}
}
for(i=flag + ;i<s.size();i++){
r = r* + s[i] - '';
}
//cout<<"r"<<r<<endl;
int k =;
while(r){
if(r%==){ //特殊情况当s[i] = Z 的时候,%26 = 0,不符合式子,而且此时 r/26 必须减一,具体为什么自己带两个数据推下就知道。
s1[k++] = 'Z';
r=r/-;}
else{
s1[k++] = 'A' + r%-;
r/=;}
}
for(i=k-;i>=;i--)
cout<<s1[i];
for(i=;i<flag;i++)
cout<<s[i];
cout<<endl;
}
}
return ;
}
codeforces 1B Spreadsheets的更多相关文章
- 【题解】codeforces 1B Spreadsheets
题意翻译 人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:第一列被标为A,第二列为B,以此类推,第26列为Z.接下来为由两个字母构成的列号: 第27列为AA,第28列为AB-在标为 ...
- CodeForces 1B Spreadsheets (字符串处理,注意细节,大胆尝试)
题目 注意模后余数为0时,要把除以26后的新数据减1,为什么这样,要靠大胆尝试.我在对小比赛中坑了一下午啊,直到比赛结束也没写出这道题....要死了.. #include<stdio.h> ...
- CodeForces 1B 模拟题。
H - 8 Time Limit:10000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- 【Codeforces 1B】Spreadsheets
[链接] 我是链接,点我呀:) [题意] A~Z分别对应了1~26 AA是27依次类推 让你完成双向的转换 [题解] 转换方法说实话特别恶心>_< int转string 得像数位DP一样一 ...
- 1B. Spreadsheets
题目大意: 行和列的两种方式. A是1, B是2,....Z是26, AA是27, AB是28........... 如: BC23代表55列23行 还有一种表示方法:R23C55, 代表23行,55 ...
- codeforces 1B 模拟
题目大意: 给出两种行列位置的表示方法,一个是Excel表示法,一个是(R,C)坐标表示.给出一种表示,输出另外一种表示. 基本思路: 模拟,首先判断是哪一种表示法,然后转换成另外一种表示方法: 我做 ...
- Codeforces Beta Round #1 B. Spreadsheets 模拟
B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular sprea ...
- Codeforces Beta Round #1 A,B,C
A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard in ...
- Codeforces 375C Circling Round Treasures - 最短路 - 射线法 - 位运算
You have a map as a rectangle table. Each cell of the table is either an obstacle, or a treasure wit ...
随机推荐
- LINQ Group By操作(转载)
假设我们需要从两张表中统计出热门商圈,这两张表内容如下: 上表是所有政区,商圈中的餐饮个数,名为FoodDistrict 下表是所有政区,商圈中的SPA个数,名为SPADistrict 现在要把这两张 ...
- vue 中使用iconfont Unicode编码线上字体图标的流程
1.打开http://www.iconfont.cn官网,搜索你想要的图标.添加字体图标到购物车,点击购物车然后添加至项目,点击确定 2.点击图标管理/我的项目,找到对应的文件,点击Unicode,然 ...
- C# 异步上传图片案例
好久没写博客了,都感觉自己快堕落了!今天随性写一篇关于异步上传图片的程序及插件! 说是程序及插件,其实程序占大头,所谓的插件只是两个JS.分别为:jquery.html5upload.js 和 jqu ...
- webpack 构建 node_modules 中公司内部组件
构建 node_modules 中特定的组件 { test:/\.js$/, exclude: /node_modules\/(?!(zt-)\/).*/, use:[ { loader:" ...
- 你真的了解volatile关键字吗?
volatile关键字经常在并发编程中使用,其特性是保证可见性以及有序性,但是关于volatile的使用仍然要小心,这需要明白volatile关键字的特性及实现的原理,这也是本篇文章的主要内容. 一. ...
- 五年.net程序员Java学习之路
大学毕业后笔者进入一家外企,做企业CRM系统开发,那时候开发效率最高的高级程序语言,毫无疑问是C#.恰逢公司也在扩张,招聘了不少.net程序员,笔者作为应届生,也乐呵呵的加入到.net程序员行列中. ...
- Zabbix监控系统部署:源码安装
1. 概述1.1 基础环境2. 部署过程2.1 创建用户组2.2 下载源码解压编译安装2.2.1 下载源码解压2.2.2 YUM安装依赖环境2.2.3 编译安装最新版curl2.2.4 更新GNU构建 ...
- bootstrap面试题
1.你能描述一下渐进增强和优雅降级之间的不同吗? 优雅降级:Web站点在所有新式浏览器中都能正常工作,如果用户使用的是老式浏览器,则代码会检查以确认它们是否能正常工作.由于IE独特的盒模型布局问题,针 ...
- 【课程总结】Linux内核分析课程总结
程涵 原创博客 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 每周实验报告: 反汇编一个简单的C程序 ...
- hash函数补分博客
题目要求: 利用除留余数法为下列关键字集合的存储设计hash函数,并画出分别用开放寻址法和拉链法解决冲突得到的空间存储状态(散列因子取0.75) 关键字集合:85,75,57,60,65,(你的8位学 ...