Spreadsheets (26进制转换)
来源:互联网 发布:右下角网络连接感叹号 编辑:程序博客网 时间:2024/06/07 00:12
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 follown lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than106 .
Output
Write n lines, each line should contain a cell coordinates in the other numeration system.
Sample Input
2R23C55BC23
BC23R23C55题意:定义了两种模式下的字符串下标,要求你转换分析:对于第一种模式,比如R23C55,取出55,那么55实际上是BC的26进制的表示形式,那么只需要按照26进制还原就行,%和/的时候注意一下整除的情况。打表然后映射也可以
另外要注意的是判断是模式一还是模式二,这里有些坑.#include<cstring>#include<string>#include<iostream>#include<queue>#include<cstdio>#include<algorithm>#include<map>#include<cstdlib>#include<cmath>#include<vector>//#pragma comment(linker, "/STACK:1024000000,1024000000");using namespace std;#define INF 0x3f3f3f3fchar ans[1000005];char s[1000005];bool judge(){ int len=strlen(s); int j; for(j=0;j<len;j++) if(s[j]>='A'&&s[j]<='Z') continue; else break; for(int i=j;i<len;i++) { if(s[i]>='0'&&s[i]<='9') continue; else return true; } return false;}int main(){ int T; scanf("%d",&T); while(T--) { scanf("%s",s); int len=strlen(s); if(judge()) { int flag=0; int s1=0,s2=0; for(int i=1;i<len;i++) { if(!flag) { if(s[i]>='0'&&s[i]<='9') s1=s1*10+(s[i]-'0'); else flag=1; } else { if(s[i]>='0'&&s[i]<='9') s2=s2*10+(s[i]-'0'); } } int p=0; while(s2) { if(s2%26==0) { ans[p++]='Z'; s2=(s2-1)/26; } else { ans[p++]=(s2%26+'A'-1); s2/=26; } } ans[p]='\0'; for(int i=p-1;i>=0;i--) printf("%c",ans[i]); printf("%d\n",s1); } else { int s1=0; int p; for(int i=0;i<len;i++) { if(s[i]>='0'&&s[i]<='9') s1=s1*10+(s[i]-'0'); if(s[i]>='A'&&s[i]<='Z') p=i; } long long temp=0; for(int i=0;i<=p;i++) { temp=temp*26+(s[i]-'A'+1); } printf("R%dC%I64d\n",s1,temp); } } return 0;}
- Spreadsheets (26进制转换)
- codeforces 1B Spreadsheets(26进制转换)
- 1B. Spreadsheets【进制转换】
- Codeforces 1B Spreadsheets(模拟+26进制思想)
- Spreadsheets
- Spreadsheets
- Spreadsheets(进制转化)(sscanf的使用)
- Google Spreadsheets
- B. Spreadsheets
- B. Spreadsheets
- codeforces_1B Spreadsheets
- D - Spreadsheets
- Codeforces Spreadsheets
- B. Spreadsheets
- google spreadsheets试用
- Google Docs & Spreadsheets Tour
- CODEFORCES:1B. Spreadsheets
- cf 1B. Spreadsheets
- Viewpager和轮播图的冲突
- iOS知识 ----加载显示gif图片
- 安卓入门学习(一)用户界面设计
- Android文件上传工具类
- js二级联动*本地
- Spreadsheets (26进制转换)
- [JavaScript/JQuery] 无需 Flash 使用 jQuery 复制文字到剪贴板
- Html+CSS transform属性中的 rotate 属性值
- centos中crontab(计时器)用法详解
- HBase深入学习(1)
- codeforces_616B. Dinner with Emma
- Linux 文件系统基础--块、i节点
- [DIV/CSS] CSS页面布局笔记
- ACE_TP_Reactor 实现 Leader-Follower 线程模型分析