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 ...
随机推荐
- jsp利用cookie记住用户名,下次登录时显示在文本框中(仅仅一个Cookie就整了将近三个小时,⊙﹏⊙b汗)
<%@page import="java.net.URLDecoder"%> <%@page import="sun.security.util.Len ...
- Zookeeper未授权访问
l 漏洞名称: zookeeper未授权访问 l 漏洞影响版本: zookeeper l 漏洞细节: ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubb ...
- xml读写文件实例
在某个通讯中需要向服务器发送请求xml,格式例子如下: <?xml version="1.0" encoding="UTF-8"?> <ROO ...
- ctrl+z暂停任务
(1) CTRL+Z挂起进程并放入后台 (2) jobs 显示当前暂停的进程 (3) bg %N 使第N个任务在后台运行(%前有空格) (4) fg %N 使第N个任务在前台运行 默认bg,fg不带% ...
- 访问Google搜索,Google学术镜像搜索
Google学术镜像搜索:http://dir.scmor.com/google/ 不用FQ也能访问谷歌搜索网站,让我们一起Google 不用FQ也能访问谷歌搜索网站,让我们一起Google(摘自:h ...
- yii 验证码的使用
在HappyController 中加入 public function actions(){ return array( // captcha action renders the CAPTCHA ...
- iOS - AVPlayer 音视频播放
前言 NS_CLASS_AVAILABLE(10_7, 4_0) @interface AVPlayer : NSObject @available(iOS 4.0, *) public class ...
- html 如何获取表格中所选行的一行数据,并赋值到对应的TEXT里面?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- QQServer_update
import java.awt.*; import javax.swing.*; import java.net.*; import java.io.*; import java.awt.event. ...
- [转载] 跟着实例学习zookeeper 的用法
原文: http://ifeve.com/zookeeper-curato-framework/ zookeeper 的原生客户端库过于底层, 用户为了使用 zookeeper需要编写大量的代码, 为 ...