CodeForces 1B
来源:互联网 发布:淘宝申请退货几天到账 编辑:程序博客网 时间:2024/06/07 02:22
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 numbern (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 .
Write n lines, each line should contain a cell coordinates in the other numeration system.
2R23C55BC23
BC23R23C55
模拟题
#include<iostream>#include<cstdio>#include<cstring>#include<string>using namespace std;int t,n,m;string s;char a[100005];int main(){ int i,j,k,temp,len,num; scanf("%d",&t); while(t--) { cin>>s; len=s.length(); temp=s.find('C'); num=0; if(s[0]=='R'&&s[1]>='0'&&s[1]<='9'&&temp>0) { for(i=temp+1;i<len;i++) num=num*10+(s[i]-'0'); j=0; while(num) { if(num%26==0) { a[j]=(char)'Z'; num--; } else { a[j]=(char)(num%26+'A'-1); } num/=26; j++; } for(i=j-1;i>=0;i--) printf("%c",a[i]); //cout<<s.substr(1,temp-1); cout<<s.substr(1,temp-1)<<endl; } else { for(i=0;i<len;i++) { if(s[i]>='0'&&s[i]<='9') { temp=i;break; } } for(i=0;i<temp;i++) { num=num*26+(s[i]-'A'+1); } //cout<<s.substr(temp)<<endl; cout<<'R'<<s.substr(temp)<<'C'<<num<<endl; } } return 0;}
- Codeforces 1B - Spreadsheet
- CODEFORCES:1B. Spreadsheets
- CodeForces 1B Spreadsheet
- Codeforces 1B Spreadsheet
- CodeForces 1B Spreadsheets
- CodeForces - 1B Spreadsheets
- Codeforces 1B. Spreadsheets
- codeforces-1B. Spreadsheets
- CodeForces 1B-Spreadsheet
- CodeForces 1B Spreadsheets
- CodeForces#1B Spreadsheets
- 【CodeForces】[1B]Spreadsheet
- Codeforces #1 B. Spreadsheets
- day2 CodeForces - 1B
- CodeForces 1B Spreadsheets
- CodeForces 1B
- codeforces 1B Spreadsheets
- Codeforces 1B Spreadsheets
- UVALive 2889 Palindrome Numbers
- GP学习(十)-Mosaic raster datasets to a file raster format
- HDU 4352 XHXJ's LIS
- C#和JAVA利用BASE64实现图片编码解码
- 容斥原理 —— 求1~n有多少个数与k互质(二进制算法详细解释&模板)
- CodeForces 1B
- Java wait(long arg)方法的使用
- golang substring方法的几种实现
- NYOJ263精挑细选
- Java调用C++ API完整示例(dll)
- 【杭电2124】Repair the Wall
- 【HTML】快速掌握 html 常用标签
- scanf()函数
- CSVs in Python