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 ...
随机推荐
- gevent异步,io自动切换
#!/usr/bin/env python # encoding: utf-8 # Date: 2018/6/19 # # from gevent import monkey # 这俩行必须放在首 ...
- Populating Next Right Pointers in Each Node II ?
void connect(TreeLinkNode *root) { if(root==NULL) return; if(root->left&&root->right) ...
- 关于学习ios开发的一些笔记
关于方法前的 + - 符号 前置加号(+)的方法为类方法,这类方法是可以直接用类名来调用的,它的作用主要是创建一个实例.相当于是静态的方法. 前置减号(-)的方法为实例方法,必须使用类的实例才可以调用 ...
- Deep Learning 学习笔记(6):神经网络( Neural Network )
神经元: 在神经网络的模型中,神经元可以表示如下 神经元的左边是其输入,包括变量x1.x2.x3与常数项1, 右边是神经元的输出 神经元的输出函数被称为激活函数(activation function ...
- Pandas统计计算和描述
Pandas统计计算和描述 示例代码: import numpy as np import pandas as pd df_obj = pd.DataFrame(np.random.randn(5,4 ...
- Halcon学习之五:有关图像的定义域的函数
1.add_channels ( Regions, Image : GrayRegions : : ) 将Image图像的灰度值赋给区域Regions,得到GrayRegions. 2.change_ ...
- ffmpeg截取一段视频中一段视频
ffmpeg -i ./plutopr.mp4 -vcodec copy -acodec copy -ss 00:00:10 -to 00:00:15 ./cutout1.mp4 -y -ss ti ...
- Spring Cloud Eureka 2 (Eureka Server搭建服务注册中心)
工具:IntelliJ IDEA 2017.1.2 x64.maven3.3.9 打开IDE file===>new===>project next next 选择相应的依赖 next ...
- Neo4j的集群架构
Neo4j的集群架构 参考资料: 1.http://lib.csdn.net/article/mysql/5742,其中有集群的集中模式master-slave.sharding.多主模式.cassa ...
- 专利系统数据库连接出现 base-64字符串中的无效字符 错误
错误提示如图: 解决方法: 1.进注册表修改如下 2.进入系统配置页面http://10.10.0.70/eaf/init 对数据库进行重新配置 3.若不行再将如下密码修改一下 重启IIS生效