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.

Examples
input
2
R23C55
BC23
output
BC23
R23C55
#include <stdio.h>
#include <string.h>
#define M 1*10^6+10 char str[M]; /* 十进制变为二十六进制 */ void solve_10_to_26(char str[])
{
char re[M];
int p = M - ;
int r, c;
sscanf(str, "R%dC%d", &r, &c); re[p--] = ; while(r)
{
re[p--] = r % + '';
r = r/;
} while(c)
{
re[p--] = (c-) % + 'A';
c = (c-)/;
} printf("%s\n", &re[p+]);
} /* 二十六进制变为十进制 */ void solve_26_to_10( char str[] )
{
char cc[M];
int c = ;
int r; sscanf( str, "%[A-Z]%d", &cc, &r ); int len = strlen(cc);
int p = ; while(p < len)
{
c = c + cc[p++] - 'A' + ;
c = c * ;
} c = c / ;
printf("R%dC%d\n", r, c);
} int main()
{
int n; scanf("%d", &n); while(n--)
{
scanf("%s", &str);
int a, b;
if ( sscanf(str, "R%dC%d", &a, &b ) == )
solve_10_to_26(str);
else
solve_26_to_10(str);
} return ;
}

B. Spreadsheets(进制转换,数学)的更多相关文章

  1. Gym-100923L-Por Costel and the Semipalindromes(进制转换,数学)

    链接: https://vjudge.net/problem/Gym-100923L 题意: Por Costel the pig, our programmer in-training, has r ...

  2. CodeForces 1B-字符串,进制转换与数学

    一个萌新的成长之路 Background 同学们都回家了,只有我和wjh还有邢神在机房敲代码,吃random口味的方便面-- Description Translated by @PC_DOS fro ...

  3. EOJ Monthly 2019.2 (based on February Selection) D 进制转换 【数学 进制转换】

    任意门:https://acm.ecnu.edu.cn/contest/140/problem/D/ D. 进制转换 单测试点时限: 2.0 秒 内存限制: 256 MB “他觉得一个人奋斗更轻松自在 ...

  4. HDU4814——数学,模拟进制转换

    本题围绕:数学公式模拟进制转换 HDU4814 Golden Radio Base 题目描述 将一个十进制的非负整数转换成E(黄金分割数)进制的数 输入 不大于10^9的非负整数,处理到文件尾 输出 ...

  5. NOIP2000 进制转换

    题一   进制转换              (18分)  问题描述      我们可以用这样的方式来表示一个十进制数: 将每个阿拉伯数字乘以一个以该数字所处位置的(值减1)为指数,以10为底数的幂之 ...

  6. JAVA之旅(一)——基本常识,JAVA概念,开发工具,关键字/标识符,变量/常量,进制/进制转换,运算符,三元运算

    JAVA之旅(一)--基本常识,JAVA概念,开发工具,关键字/标识符,变量/常量,进制/进制转换,运算符,三元运算 Android老鸟重新学一遍JAVA是什么感觉?枯燥啊,乏味啊,而且归纳写博客,都 ...

  7. python 内置函数 进制转换

    4.内置函数 自定义函数 内置函数 len Open id() type() range() 输入输出 print() input() 强制转换 int() float() list() tuple( ...

  8. JavaSE学习(二):进制转换—数据类型转换—Java运算符

    一.进制转换 1.1 其他进制转十进制(以十六进制为例): 十六进制范围:0-9, A-F对应数字10-15 2A7E(16)  =  14*16(0) +7*16(1) + 10*16(2)  + ...

  9. 进制转换(NOIP2000&NOIP水题测试(2017082301))

    题目链接:进制转换 这题得明白其中的数学方法,明白后就不难了. 那么我们应该怎么计算呢? 其实也很简单. 我们依然采取辗转相除法. 但是,对于负的余数,我们需要进行一些处理. 我们怎么处理呢? 很简单 ...

  10. python 数据类型、进制转换

    数据类型 存储单位 最小单位是bit,表示二进制的0或1,一般写作b 最小的存储单位是字节,用byte表示,1B = 8b 1024B = 1KB 1024KB = 1MB 1024MB = 1GB ...

随机推荐

  1. python学习(九) 魔法方法、属性和迭代器

    9.1 准备工作 python 3.0的所有类都会隐式地成为object的子类. 9.2 构造方法 在python中创建一个构造方法:只要把init方法的名字修改为魔法版本__init__即可. &g ...

  2. mac常用命令(随时更新)

    mac 强制退出快捷键 1.使用键盘快捷键强制退出处于活跃状态的Mac程序 快捷键:Command+Option+Shift+Esc 这样按住一两秒钟,就可以强制退出当前程序了,算是最方便的一种方法. ...

  3. Python web框架 Tornado(二)异步非阻塞

    异步非阻塞 阻塞式:(适用于所有框架,Django,Flask,Tornado,Bottle) 一个请求到来未处理完成,后续一直等待 解决方案:多线程,多进程 异步非阻塞(存在IO请求): Torna ...

  4. 浅层神经网络 反向传播推导:MSE softmax

    基础:逻辑回归 Logistic 回归模型的参数估计为什么不能采用最小二乘法? logistic回归模型的参数估计问题不能“方便地”定义“误差”或者“残差”. 对单个样本: 第i层的权重W[i]维度的 ...

  5. Python中的 set 与 深浅拷贝

    字符串 join() 格式:   "拼接的东西".join(可迭代对象) 可以加列表转换成字符串 lis = ['a','b','c','d'] s = "//" ...

  6. 【转】VS 安全开发生命周期(SDL)检查

    前面在学习使用google的protobuf时在VS2012中一直无法编译编译通过,经过查找一些资料原来发现,并不是protobuf的问题,而是自己在使用VS2012时,没有完全了解VS2012的强大 ...

  7. System.Security.Cryptography.CryptographicException: 出现了内部错误。

    引用:http://www.cnblogs.com/ithome8/p/5189926.html 我总结了一下出现证书无法加载的原因有以下三个 1.证书密码不正确,微信证书密码就是商户号 解决办法:请 ...

  8. Java,猜猜输出是什么?

    看看下面代码的输出是什么: public class MemoeryManager { public static void main(String[] args){ String a="a ...

  9. FastDFS介绍和配置过程 二

      最近在研究负载均衡和集群,其中涉及到一个主要问题是,如何让集群中的real server共享一套文件系统.在网上查到FastDFS,国人(happy fish,感谢他的开源精神)开发的一套轻量级分 ...

  10. Docker学习笔记_初装的Centos无ifconfig

    新创建了centos容器,使用ifconfig,报无此命令. 解决办法,使用yum进行安装ifconfig 1.yum search ifconfig 2.yum install net-tools. ...