B. Spreadsheets

题目连接:

http://www.codeforces.com/contest/1/problem/B

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

Sample Output

BC23
R23C55

Hint

题意

表格有两种表示方法,第一种

比如R23C55,就表示第23行,55列

第二种:

比如BC23,就表示在第BC列,23行,BC是一个26进制数,A是1,Z是26,BC就表示55=2*26+3

然后给你其中一种,让你转化成另外一种

题解:

模拟题,瞎跑跑就好了……

简单模拟题,进制转换,直接看(这个数-1)%26就好了。

代码

#include<bits/stdc++.h>
using namespace std;string s;
void solve1()
{int R=0,C=0;int flag = 0;for(int i=1;i<s.size();i++){if(s[i]=='C')flag=1;if(s[i]=='C')continue;if(flag==0)R=R*10+(s[i]-'0');else C=C*10+(s[i]-'0');}string ans;while(C){int p = (C-1)%26;C=(C-1)/26;ans+=(p+'A');}reverse(ans.begin(),ans.end());cout<<ans<<R<<endl;
}
void solve2()
{int flag = 0;int C=0;for(int i=0;i<s.size();i++){if(s[i]<='9'&&s[i]>='0'&&flag==0){flag = 1;cout<<"R";}if(flag==1)cout<<s[i];elseC=C*26+(s[i]-'A'+1);}cout<<"C"<<C<<endl;
}
int main()
{int time;scanf("%d",&time);while(time--){cin>>s;int flag1=0,flag2=0,flag3=0;for(int i=0;i<s.size();i++){if(s[i]=='R')flag1++;if(s[i]=='C')flag2++;if(s[i]<='Z'&&s[i]>='A')flag3++;}if(s[0]=='R'&&s[1]=='C')flag1=0;if(flag3==2&&flag1&&flag2)solve1();elsesolve2();}
}

转载于:https://www.cnblogs.com/qscqesze/p/5248802.html

Codeforces Beta Round #1 B. Spreadsheets 模拟相关推荐

  1. Codeforces Beta Round #5 B. Center Alignment 模拟题

    B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...

  2. codeforces beta round 1

    codeforces beta round 1 A Theatre Square in the capital city of Berland has a rectangular shape with ...

  3. Codeforces Beta Round #7

    Codeforces Beta Round #7 http://codeforces.com/contest/7 A 水题 1 #include<bits/stdc++.h> 2 usin ...

  4. Codeforces Beta Round #17 D. Notepad (数论 + 广义欧拉定理降幂)

    Codeforces Beta Round #17 题目链接:点击我打开题目链接 大概题意: 给你 \(b\),\(n\),\(c\). 让你求:\((b)^{n-1}*(b-1)\%c\). \(2 ...

  5. Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树。单点更新

    http://codeforces.com/problemset/problem/91/B 题意: 给你n个数,求得i 到n中小于a[i]的最右边的a[j],然后求a[i]到a[j]之间包含了多少个数 ...

  6. Codeforces Beta Round #51 D. Beautiful numbers 数位dp + 状态优化

    传送门 文章目录 题意: 思路: 题意: 思路: 数位dpdpdp挺经典的一个题辣,有一个很明显的状态就是f[pos][num][lcm]f[pos][num][lcm]f[pos][num][lcm ...

  7. Codeforces Beta Round #22 (Div. 2 Only) E. Scheme(DFS+强连通)

    题目大意 给了 n(2<=n<=105) 个点,从每个点 u 出发连向了一个点 v(共 n 条边) 现在要求添加最少的边使得整个图是一个强连通图 做法分析 这道题千万不要一般化:先求强连通 ...

  8. Codeforces Beta Round #4 (Div. 2 Only)

    Codeforces Beta Round #4 (Div. 2 Only) A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 ...

  9. Codeforces Beta Round #1:B. Spreadsheets

    题意:对于当前位置(x, y),有两种表示方法:①RxCy:②F(y)x 其中F(y)表示y的一种转换方法:1→A,2→B--26→Z,27→AA,28→AB以此类推 n次询问,每次给你一种表示方式, ...

  10. 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 ...

最新文章

  1. torch.bmm()函数的使用
  2. 深度睡眠中,记忆如何被保持?
  3. linux i2c ioctl错误,关于读写I2C总线的时候出错的有关问题
  4. 微软发布的python教程_微软发布Python 教程《Develop with Python on Windows》
  5. 计算机二级二叉树基础知识,2017年计算机二级公共基础知识学习教程:树与二叉树...
  6. 改进初学者的PID-修改整定参数
  7. 【2015年第4期】大数据时代的数据挖掘 —— 从应用的角度看大数据挖掘(上)...
  8. 如何用互联网思维搞定零售业
  9. Silverlight XPS阅读器,支持分页、查找、全屏、缩放
  10. JMM理论二:相关概念——重排序、内存屏障、数据依赖、as-if-serial、final、Happen-Before
  11. 直播换脸后,我们来搞搞微信QQ聊天换脸!| avatarify
  12. 前端面试 计算机网络篇
  13. 论文中的参考文献序号自动链接到对应的参考文献
  14. LibFuzzer学习(一):轻松找到心脏出血漏洞
  15. Python控制键盘鼠标pynput的详细用法 (转载)
  16. RAM/ROM存储器的设计
  17. 为什么要使用回调函数?(这个回答太精彩了)
  18. 通过ActiveWorkbook.Sheets.Add将新表插入到最后的代码
  19. 计算机类公务员 真题解析,公务员考试C类计算机考试真题及答案2[文].pdf
  20. 浅谈erlang游戏服务器项目--英雄远征服务启动流程

热门文章

  1. html 导航菜单切换效果,纯CSS实现Tab导航栏切换
  2. oracle系统AP对应的凭证编号,AP主要账户及会计分录
  3. 优酷ts转换mp4_下载腾讯视频并转成MP4
  4. Pytorch 入门之数据处理 -- Dataset、Sampler、DataLoader
  5. android模拟器 bridge,ADB (Android Debug Bridge)简介
  6. [转载]Qlist的用法
  7. Ubuntu下VIM的安装和基本用法
  8. CSS 3的display:盒类型详解
  9. android 图片素描算法
  10. 【鱼眼镜头5】[中央全向相机畸变模型]:统一相机模型,四阶多项式对统一相机模型进行建模