B. Spreadsheets
time limit per test

10 seconds

memory limit per test

64 megabytes

input

standard input

output

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.

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 test(s)
Input
  1. 2
    R23C55
    BC23
Output
  1. BC23
    R23C55
  2.  
  3. 代码:
  1. #include<iostream>
  2. #include<cstring>
  3. #include<cstdio>
  4. using namespace std;
  5. int main()
  6. {
  7. int n,i;
  8. char str[];
  9. bool flag;
  10. //freopen("test.in","r",stdin);
  11. //freopen("test.out","w",stdout);
  12. scanf("%d",&n);
  13. while(n--){
  14. scanf("%s",str);
  15. flag=true;
  16. int len=strlen(str);
  17. if(str[]>=''&&str[]<=''){
  18. for(i=;i<len;i++){
  19. if(str[i]>='A'&&str[i]<='Z'){
  20. //说明是第二种格式r--c--
  21. char ss[]="\0";
  22. strncpy(ss,str+,i-);
  23. //printf("%s%s\n",str+i+1,ss);
  24. //先转化为整数
  25. int ans=;
  26. int t=;
  27. i++;
  28. while((len--)>i){
  29. ans+=((int)(str[len]-''))*t;
  30. t*=;
  31. }
  32. i=;
  33. int st[]={};
  34. while(ans>){
  35. //temp=work(i);
  36. if(ans%==){
  37. if(ans>=)st[i++]=;
  38. else st[i++]=ans;
  39. ans/=;
  40. ans--;
  41. }
  42. else{
  43. st[i++]=ans%;
  44. ans/=;
  45. }
  46. }
  47. for(--i;i>=;i--){
  48. if(st[i]) putchar((st[i]-+'A'));
  49. else putchar('Z');
  50. }
  51. printf("%s\n",ss);
  52. flag=false;
  53. break;
  54. }
  55. }
  56. }
  57. //第一种格式
  58. if(flag) {
  59. char ss[]="\0";
  60. int k=;
  61. for( i=;i<len;i++){
  62. if(str[i]>='A'&&str[i]<='Z')
  63. ss[k++]=str[i];
  64. else break;
  65. }
  66. printf("R%sC",str+i);
  67. int ans=,t=;
  68. while(k--){
  69. ans+=((int)(ss[k]-'A')+)*t;
  70. t*=;
  71. }
  72. printf("%d\n",ans);
  73. }
  74. }
  75. return ;
  76. }

cf------(round)#1 B. Spreadsheets(模拟)的更多相关文章

  1. Codeforces Beta Round #1 B. Spreadsheets 模拟

    B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular sprea ...

  2. CF Round #600 (Div 2) 解题报告(A~E)

    CF Round #600 (Div 2) 解题报告(A~E) A:Single Push 采用差分的思想,让\(b-a=c\),然后观察\(c\)序列是不是一个满足要求的序列 #include< ...

  3. CF round #622 (div2)

    CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...

  4. CF Round #551 (Div. 2) D

    CF Round #551 (Div. 2) D 链接 https://codeforces.com/contest/1153/problem/D 思路 不考虑赋值和贪心,考虑排名. 设\(dp_i\ ...

  5. CF Round #510 (Div. 2)

    前言:没想到那么快就打了第二场,题目难度比CF Round #509 (Div. 2)这场要难些,不过我依旧菜,这场更是被\(D\)题卡了,最后\(C\)题都来不及敲了..最后才\(A\)了\(3\) ...

  6. UOJ #30. [CF Round #278] Tourists

    UOJ #30. [CF Round #278] Tourists 题目大意 : 有一张 \(n\) 个点, \(m\) 条边的无向图,每一个点有一个点权 \(a_i\) ,你需要支持两种操作,第一种 ...

  7. 竞赛题解 - CF Round #524 Div.2

    CF Round #524 Div.2 - 竞赛题解 不容易CF有一场下午的比赛,开心的和一个神犇一起报了名 被虐爆--前两题水过去,第三题卡了好久,第四题毫无头绪QwQ Codeforces 传送门 ...

  8. 【前行&赛时总结】◇第4站&赛时9◇ CF Round 513 Div1+Div2

    ◇第4站&赛时9◇ CF Round 513 Div1+Div2 第一次在CF里涨Rating QWQ 深感不易……作blog以记之 ( ̄▽ ̄)" +Codeforces 的门为你打 ...

  9. CF Round #580(div2)题解报告

    CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然 ...

  10. 【codeforces】【比赛题解】#915 Educational CF Round 36

    虽然最近打了很多场CF,也涨了很多分,但是好久没写CF的题解了. 前几次刚刚紫名的CF,太伤感情了,一下子就掉下来了,不懂你们Div.1. 珂学的那场我只做了第一题……悲伤. 这次的Education ...

随机推荐

  1. [转]Unity 延迟执行一段代码的较为优雅的方式

    Unity中,延时执行一段代码或者一个方法或者几个方法的情况非常普遍. 一般会用到Invoke和InvokeRepeating方法.顾名思义,第一个是执行一次,第二个是重复执行. 看下定义: void ...

  2. 协方差Covariance的表述推导

    今天想了一下关于概率论的一维数据期望.方差以及高维数据的矩阵表示,突然想到为什么在一维中 方差的表示为:V(x) = E((x-E(x))2) 而到了高维,这样的表述就成了协方差呢?V(X) = E( ...

  3. 如何查看postfix的版本

    [root@localhost sasl2]# postconf -d | grep mail_versionmail_version = 2.10.1milter_macro_v = $mail_n ...

  4. Changing Icon File Of Push Button At Runtime In Oracle Forms 6i

    Set Icon_File property in When-Mouse-Enter trigger Suppose you are creating icon based menu system i ...

  5. IIS网站部署注意点

    在IIS上部署网站时,除了在添加网站时配置好相关程序池,主目录,安全性,选择.Netframwork版本这些步骤外, 容易忘记的是有些网站需要打开web服务扩展.

  6. Java——Image 图片合并

    1.合并图片 package com.tb.image; import java.awt.Image; import java.awt.image.BufferedImage; import java ...

  7. CSS笔记(一)CSS规则

    CSS是层叠式样式表(Cascading Style Sheets)的缩写,定义了如何显示HTML元素. CSS规则由两个主要的部分构成:选择器 + 一条或多条声明. 每条声明由一个属性和一个值构成. ...

  8. Python numpy学习笔记(一)

    下边代码是关于numpy的一些基本用法,包括数组和矩阵操作等... import numpy as np print "<== print version ==>" p ...

  9. css3,环绕圆环 loading,小组件

    一个loading的小组件, 给其他模块调用.先上图 type:cat type:ball 第一幅loading,老鼠是一个圆形的背景图片,已经转成base64. 小猫也是图片 也已经转成base64 ...

  10. awt组件中文乱码Intellij解决

    -Dfile.encoding=GB18030 -Dfile.encoding=GB18030