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. class_create(),class_device_create()创建/dev/xxx 名字

    在刚开始写Linux设备驱动程序的时候,很多时候都是利用mknod命令手动创建设备节点,实际上Linux内核为我们提供了一组函数,可以用来在模块加载的时候自动在/dev目录下创建相应设备节点,并在卸载 ...

  2. mul 指令

    mul 是乘法指令 两个相乘的数:两个相乘的数,要么都是 8 位,要么都是 16 位. 如果是 8 位,一个默认放在 AL 中,另一个放在 8 位寄存器或内存字节单元中: 如果是 16 位,一个默认在 ...

  3. 使用Kismet进行网络扫描

    执行命令启动Kismet root@sch01ar:~# kismet 这个界面是用来设置颜色的,单击Yes按钮,默认颜色灰色 这个界面显示正在使用root用户运行Kismet工具,单击OK 这个界面 ...

  4. SSD知识

    不管什么接口的SSD,一般都由以下部分组成:主控,Flash,板,壳,品牌.下面本佬就这些部分一一发帖,仅供娱乐参考,不作任何推荐和偏向,有不同见解请直接发表,有任何错误,请直接指正,不为吵架,只为娱 ...

  5. 用sysbench压测MySQL,通过orzdba监控MySQL

    1.1 安装sysbench wget https://codeload.github.com/akopytov/sysbench/zip/0.5 unzip 0.5 cd sysbench-0.5/ ...

  6. MIDL相关

    根据MIDL的语义, 指针总被认为是指向单一元素而不是数组.因此以上方法中只有串中的第一个字符被封送.为此,MIDL引入了[string]特性来说明传递的是一个字符串 http://www.cnblo ...

  7. 结合spring 实现自定义注解

    注解类 import java.lang.annotation.*; /** * Created by Administrator on 2016/6/28. */ //ElementType.MET ...

  8. Eclipse下使用Subversion(SVN工具)

    本文目的 让未使用过版本控制器软件或者未使用过subversion软件的人员尽快上手. subversion的使用技巧很多,这里只总结了最小使用集,即主要的基本功能,能够用来应付日常工作. 因此不涉及 ...

  9. 用java和汇编开发一个hello world系统内核

  10. qt数据库有效插件为空的情况

    打了一周的环境,从ubuntu到win7,搭建环境的时间比写代码的时间都多.先简单的介绍一下我搭建的环境不是纯QT环境,是一个芬兰的软件开发商开发出来的SDK里面完全融合qt,其中qt是以单独的目录存 ...