题意翻译

人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:

第一列被标为A,第二列为B,以此类推,第26列为Z。接下来为由两个字母构成的列号: 第27列为AA,第28列为AB...在标为ZZ的列之后则由三个字母构成列号,如此类推。

行号为从1开始的整数。

单元格的坐标由列号和行号连接而成。比如,BC23表示位于第55列23行的单元格。

有时也会采用被称为RXCY的坐标系统,其中X与Y为整数,坐标(X,Y)直接描述了对应单元格的位置。比如,R23C55即为前面所述的单元格。

您的任务是编写一个程序,将所给的单元格坐标转换为另一种坐标系统下面的形式。

输入

第一行一个整数n(1<=n<=10^5),表示将会输入的坐标的数量。

接下来n行,每行一个坐标。

注意: 每个坐标都是正确的。此外不会出现行号或列号大于10^6的单元格。

输出

n行,每行一个被转换的坐标。

输入格式:

2

R23C55

BC23

输出格式:

BC23

R23C55

分析:这道题其实挺简单的,想到就是将十进制的数转换为二十六进制就可以了,然后注意一下当n2%26==0的时候是'A'就可以了

 #include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
using namespace std;
char a[]; void solve1(){
int len=strlen(a);
int i;
int n1=,n2=;
int flag=;
for( i=; i<len; i++ ){
if(a[i]>=''&&a[i]<=''&&flag==){
n1=n1*+(a[i]-'');
}
else if(a[i]>=''&&a[i]<=''&&flag==){
n2=n2*+(a[i]-'');
}
else{
flag=;
}
}
// cout<<"n1="<<n1<<" n2="<<n2<<endl;
char temp[];
int pos=;
while(n2!=){
int t=n2%;
if(t==) temp[pos++]='A';
else{
temp[pos++]=(char)(+t-);
}
n2/=;
}
for( int i=pos-; i>=; i-- ){
cout<<temp[i];
}
cout<<n1<<endl;
} void solve2(){
// cout<<a<<endl;
int len=strlen(a);
int t=;
for( int i=; i<len; i++ ){
if(!(a[i]>='A'&&a[i]<='Z')){
t=i-;
break;
}
}
double m2=;
for( int i=; i<=t; i++ ){
m2=m2+(a[i]-'A'+)*(pow(,(t-i)));
// cout<<"a[i]-'A'+1="<<a[i]-'A'+1<<" "<<pow(26,(t-i))<<endl;
// cout<<"m2="<<m2<<endl;
}
cout<<'R';
for( int i=t+; i<len; i++ ){
cout<<a[i];
}
cout<<'C'<<m2<<endl;
} int main(){
int n;
cin>>n;
while(n--){
cin>>a;
if(a[]=='R'&&a[]>=''&&a[]<=''){
// cout<<a<<endl;
solve1();
}
else{
solve2();
}
}
return ;
}

但是在做这道题的时候有个很气愤的事,如果你把52行的double m2=0;改成int m2=0;(笔者实在codeblocks,,,MINGW编译器下跑的程序),会发现结果是不对的,样例二得出结果是m2=51

这个去看了下pow函数的源码,。。。。问了下大佬们,pow是很玄学的东西,所以大家在写东西的时候尽量避开pow函数,自己写个for循环鸭,也不长。。。

CF1B Spreadsheets的更多相关文章

  1. CF1B.Spreadsheets(电子表格) 题解 模拟

    作者:zifeiy 标签:模拟 题目出处:Spreadsheets 题目描述 在流行的电子表格系统中(例如,在Excel中),使用如下计算方式来对列号进行计算. 第1列对应A,第2列对应B,--,第2 ...

  2. cf------(round)#1 B. Spreadsheets(模拟)

    B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...

  3. CF Spreadsheets (数学)

    Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard input ...

  4. Spreadsheets

    很水的一道题,提醒自己要认真,做的头都快晕了.考虑26的特殊情况. D - Spreadsheets Time Limit:10000MS     Memory Limit:65536KB     6 ...

  5. codeforces 1B Spreadsheets

    In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is u ...

  6. Codeforces Beta Round #1 B. Spreadsheets 模拟

    B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular sprea ...

  7. B. Spreadsheets(进制转换,数学)

    B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...

  8. C#-使用GoogleAPI读写spreadsheets

    https://docs.google.com/spreadsheets/在线使用一些常用办公工具,比如excel. 如需要C#代码自动读写这些excel,则需要使用GoogleAPI. 封装的公用类 ...

  9. 【题解】codeforces 1B Spreadsheets

    题意翻译 人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:第一列被标为A,第二列为B,以此类推,第26列为Z.接下来为由两个字母构成的列号: 第27列为AA,第28列为AB-在标为 ...

随机推荐

  1. 终于考完PMP

    快到年底,上手了GO语言,搞定了广告后台,觉得年底前应该不忙; 我们的PM也报了PMP,可以一起报团学习,后来由于地理位置关系,我们项目组,三个人报了不同的班,也好,信息可以共享; 跟我们公司合作的培 ...

  2. Android编码学习之Fragment

    1. 什么是Fragment Fragment是Android honeycomb 3.0新增的概念,Fragment名为碎片不过却和Activity十分相似.Fragment是用来描述一些行为或一部 ...

  3. 解析 .Net Core 注入——注册服务

    在学习 Asp.Net Core 的过程中,注入可以说是无处不在,对于 .Net Core 来说,它是独立的一个程序集,没有复杂的依赖项和配置文件,所以对于学习 Asp.Net Core 源码的朋友来 ...

  4. 生产环境CPU过高问题定位

    问题描述:       生产环境下的某台tomcat7服务器,在刚发布时的时候一切都很正常,在运行一段时间后就出现CPU占用很高的问题,基本上是负载一天比一天高. 解决过程: 1.根据top命令,发现 ...

  5. 摘:PC客户端 XP兼容性调查

    现象1:XP SP2下,客户端安装失败(或者启动失败) 解决方案:需要安装以下3个补丁(已经集成到安装包中) ==系统Hotfix(仅仅XP SP2需要安装): http://support.micr ...

  6. mybatis整合hikariCP(非spring)

    mybatis整合hikariCP(非spring) 一.配置hikariCP典型的配置文件hikariPool.properties jdbcUrl=jdbc:mysql://localhost:3 ...

  7. hive SQL 行转列 和 列转行

    一.行转列的使用 1.问题 hive如何将 a       b       1a       b       2a       b       3c       d       4c       d  ...

  8. 查看PostgreSQL正在执行的SQL

    SELECT procpid, START, now() - START AS lap, current_query FROM ( SELECT backendid, pg_stat_get_back ...

  9. Unity3D修改LWRP,HDRP的几项小问题及解决

    最近在看Book of the Dead的demo,其中对HDPR进行修改以构建自己的SRP,于是自己尝试了下.. 一般直接去Github下载对应unity版本的SRP工程: https://gith ...

  10. np.corrcoef()方法计算数据皮尔逊积矩相关系数(Pearson's r)

    上一篇通过公式自己写了一个计算两组数据的皮尔逊积矩相关系数(Pearson's r)的方法,但np已经提供了一个用于计算皮尔逊积矩相关系数(Pearson's r)的方法 np.corrcoef()  ...