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 ...
随机推荐
- Unicode 和 UTF-8关系
unicode 就是 “与存储无关的表示”,utf—8 就是 “二进制表示”.一句话,utf8是对unicode字符集进行编码的一种编码方式,utf8是给unicode字符集加了一个存储类型前缀. u ...
- Kali终端美化
首先安装figlet和cowsay root@sch01ar:~# apt-get install figlet root@sch01ar:~# apt-get install cowsay 用lea ...
- vue-cli中的babel配置文件.babelrc详解
本文介绍vue-cli脚手架工具根目录的babelrc配置文件 介绍 es6特性浏览器还没有全部支持,但是使用es6是大势所趋,所以babel应运而生,用来将es6代码转换成浏览器能够识别的代码 ba ...
- 分布式爬虫搭建系列 之二-----神器PyCharm的安装
这里我们使用PyCharm作为开发工具,以下过程摘抄于:http://blog.csdn.net/qq_29883591/article/details/52664478 作者:陌上行走 Pytho ...
- coprime Sequence
Do you know what is called ``Coprime Sequence''? That is a sequence consists of nn positive integers ...
- @RequestParam注解的作用
1.这个注解是干什么的??? 提取和解析请求参数的能力. 2.实例解析: a.代码 @Controller @RequestMapping("/pets") @SessionAtt ...
- sql server2008 跨服务器之间复制表数据
首先2个数据库要能互相访问,在本地数据库用 select * into 新表 from opendatasource('SQLOLEDB','Data Source=远程数据库IP;User ID=用 ...
- 如何将Eclipse中的开源项目使用到Android Studio中
近几日,笔者用到了一些开源项目,比如著名的PTR项目.但是在使用的过程中,遇到了一些问题. 这个开源库是在Eclipse上面写的,我们现在开发用的是Android stuido. 两种软件的项目结构是 ...
- 基于unittest测试框架的扩展
1 unittest介绍 Unittest,Python自带的单元测试框架,PyUnit类包含TestResult,TestCase, TestSuite,TextTestResult,TextTes ...
- HTML中meta标签的作用与使用
META标签用来描述一个HTML网页文档的属性 META标签可分为两大部分:HTTP-EQUIV和NAME变量. HTTP实例 HTML代码实例中有一项内容是 <meta http-equiv= ...