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 <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(进制转换,数学)的更多相关文章
- Gym-100923L-Por Costel and the Semipalindromes(进制转换,数学)
链接: https://vjudge.net/problem/Gym-100923L 题意: Por Costel the pig, our programmer in-training, has r ...
- CodeForces 1B-字符串,进制转换与数学
一个萌新的成长之路 Background 同学们都回家了,只有我和wjh还有邢神在机房敲代码,吃random口味的方便面-- Description Translated by @PC_DOS fro ...
- EOJ Monthly 2019.2 (based on February Selection) D 进制转换 【数学 进制转换】
任意门:https://acm.ecnu.edu.cn/contest/140/problem/D/ D. 进制转换 单测试点时限: 2.0 秒 内存限制: 256 MB “他觉得一个人奋斗更轻松自在 ...
- HDU4814——数学,模拟进制转换
本题围绕:数学公式模拟进制转换 HDU4814 Golden Radio Base 题目描述 将一个十进制的非负整数转换成E(黄金分割数)进制的数 输入 不大于10^9的非负整数,处理到文件尾 输出 ...
- NOIP2000 进制转换
题一 进制转换 (18分) 问题描述 我们可以用这样的方式来表示一个十进制数: 将每个阿拉伯数字乘以一个以该数字所处位置的(值减1)为指数,以10为底数的幂之 ...
- JAVA之旅(一)——基本常识,JAVA概念,开发工具,关键字/标识符,变量/常量,进制/进制转换,运算符,三元运算
JAVA之旅(一)--基本常识,JAVA概念,开发工具,关键字/标识符,变量/常量,进制/进制转换,运算符,三元运算 Android老鸟重新学一遍JAVA是什么感觉?枯燥啊,乏味啊,而且归纳写博客,都 ...
- python 内置函数 进制转换
4.内置函数 自定义函数 内置函数 len Open id() type() range() 输入输出 print() input() 强制转换 int() float() list() tuple( ...
- JavaSE学习(二):进制转换—数据类型转换—Java运算符
一.进制转换 1.1 其他进制转十进制(以十六进制为例): 十六进制范围:0-9, A-F对应数字10-15 2A7E(16) = 14*16(0) +7*16(1) + 10*16(2) + ...
- 进制转换(NOIP2000&NOIP水题测试(2017082301))
题目链接:进制转换 这题得明白其中的数学方法,明白后就不难了. 那么我们应该怎么计算呢? 其实也很简单. 我们依然采取辗转相除法. 但是,对于负的余数,我们需要进行一些处理. 我们怎么处理呢? 很简单 ...
- python 数据类型、进制转换
数据类型 存储单位 最小单位是bit,表示二进制的0或1,一般写作b 最小的存储单位是字节,用byte表示,1B = 8b 1024B = 1KB 1024KB = 1MB 1024MB = 1GB ...
随机推荐
- git学习2 - 安装
msysgit是Windows版的Git,从https://git-for-windows.github.io下载(网速慢的同学请移步国内镜像),然后按默认选项安装即可. 安装完成后,在开始菜单里找到 ...
- python学习(十五) 屏幕抓取
15.1 屏幕抓取 15.1.1 Tidy和XHTML解析 Tidy:用来修复不规范且随意的HTML文档的工具. 为什么用XHTML: 和旧版本的HTML之间最主要的区别:HTML可能只用一个开始标签 ...
- 分析java类的静态成员变量初始化先于非静态成员变量
依上图中当class字节码文件被jvm虚拟机加载到内存中依次经过 连接 验证:对字节码进行验证 准备:给静态变量分配内存并赋予变量类型各自的默认值(注:基本类型为0或false,对象为null,sta ...
- Lambda语句中创建自定义类型时,也可指定某种特定类型,方法是在new与{}之间写上类型名称
如: var fc =...ChildFath = fc.Select(c => new Child_Father { child = c.child, father = c.father }) ...
- AE插件之SKYBOX CONVERTER
AE插件之SKYBOX CONVERTER AE插件SKYBOX CONVERTER的主要作用是开发全景视频或者制作全景图片时,对添加的字幕.图片进行扭曲. 下载目录:http://www.gfxca ...
- 玩转angularJs——通过自定义ng-model,不仅仅只是input可以实现双向数据绑定
体验更优排版请移步原文:http://blog.kwin.wang/programming/angularJs-user-defined-ngmodel.html angularJs双向绑定特性在开发 ...
- chart左侧
左侧单位 Chart1.Axes.Left.Minimum := ; Chart1.Axes.Left.Maximum := Series1.YValues.MaxValue * ; Chart1.A ...
- Win10系统windows mobile设备中心无法连接WinCE采集器
1.开始-->运行,输入services.msc回车 2.在打开的服务界面中,找到“基于Windows Mobile 2003的连接设备” 3.右击属性,修改成自动 4.点击登陆选项卡,选择本地 ...
- linux启动lcd屏如水纹状波动,不稳…
开发环境:arm-s3c2416.ubuntu. 内核:linux2.6.26 病症:内核启动时,arm的lcd屏幕出现抖动现象,如水纹状波动,屏幕最下面还有白线闪动,甚至lcd有很多亮点等现象 分析 ...
- resin3.X那些事之resin.conf
[经验总结]resin那些事之resin.conf ----by johnson 话说与resin打交道很久了,却从未系统了解过.resin一听火了,说:你老兄当真与我打交道很久了?工具.流程如此发达 ...