题目大意:

给出两种行列位置的表示方法,一个是Excel表示法,一个是(R,C)坐标表示。给出一种表示,输出另外一种表示。
基本思路:
模拟,首先判断是哪一种表示法,然后转换成另外一种表示方法;
我做的时候,在(R,C)表示法转换成excel表示法的时候出了点问题,那个数字转字母的部分不会写了,所以借鉴了网上的代码:
代码如下:
//我没有处理好的部分
int tot=0;
while(N){
if(N%26==0){
res[tot++]='Z';
N=N/26-1;
}else{
res[tot++]='A'-1+N%26;
N=N/26;
}
} //题解代码:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm> using namespace std; typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 100000+10; char str[maxn];
char res[maxn];
int main(){
int n;
while(scanf("%d",&n)==1){
while(n--){
scanf("%s",str);
int len=strlen(str);
for(int i=0;i<len;i++){
if(str[i]>='a'&&str[i]<='z') str[i]=str[i]-'a'+'A';
}
int i=0;
while(i<len&&isalpha(str[i])){
i++;
}
while(i<len&&isdigit(str[i])){
i++;
}
if(i>=len){
int C=0,N=0;
int id=0;
while(id<len&&isalpha(str[id])){
C=C*26+str[id]-'A'+1;
id++;
}
while(id<len&&isdigit(str[id])){
N=N*10+str[id]-'0';
id++;
}
printf("R%dC%d\n",N,C);
}else{
int C=0,N=0;
int id=1;
while(id<len&&isdigit(str[id])){
C=C*10+str[id]-'0';
id++;
}
id++;
while(id<len&&isdigit(str[id])){
N=N*10+str[id]-'0';
id++;
}
int tot=0;
while(N){
if(N%26==0){
res[tot++]='Z';
N=N/26-1;
}else{
res[tot++]='A'-1+N%26;
N=N/26;
}
}
for(int i=tot-1;i>=0;i--) printf("%c",res[i]);
printf("%d\n",C);
}
}
}
return 0;
}

  

codeforces 1B 模拟的更多相关文章

  1. CodeForces 1B 模拟题。

    H - 8 Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  2. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  3. CodeForces - 404B(模拟题)

    Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  4. Codeforces 709B 模拟

    B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  5. CodeForces - 404A(模拟题)

    Valera and X Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  6. Codeforces 390A( 模拟题)

    Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  7. Codeforces 452D [模拟][贪心]

    题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...

  8. CodeForces - 796B 模拟

    思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...

  9. CodeForces - 864C-Bus-(模拟加油站问题)

    https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...

随机推荐

  1. Bootstrap 网页1

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  2. OpenLayers学习笔记(十二)— 飞机速度矢量线预测(二)

    根据计算公式实现预测线 作者:狐狸家的鱼 GitHub:八至 之前有一篇博客简单写了一个模拟demo,根据物体当前的速度和方向预测多少时间后所在的位置,具体计算是参考<(译)计算距离.方位以及更 ...

  3. 当input中的内容改变时触发的事件

    当input中的内容改变时触发的事件 1 $('#id').bind('input propertychange', function() { //处理内容 } 循环js事件 $(document). ...

  4. php number_format()函数 语法

    php number_format()函数 语法 number_format()函数怎么用? php number_format()函数表示通过千位分组来格式化数字,语法是number_format( ...

  5. SCP-Py-002

    项目编号:Py-002 项目等级:EuclidKeter 特殊收容措施: Py-002-1目前被映射在Researcher Kevin的服务器位于Site-Pyproject地下防无线电渗透室且被切断 ...

  6. Python基础(三):简化除法判断、分析apache访问日志、扫描存活主机、利用多线程实现ssh并发访问

    一.简化除法判断 目标: 编写mydiv.py脚本,主要要求如下: 提示用户输入一个数字作为除数 如果用户按下Ctrl+C或Ctrl+D则退出程序 如果用户输入非数字字符,提示用户应该输入数字 如果用 ...

  7. 【HDOJ6581】Vacation(模拟)

    题意:有标号从0到n的n+1辆车,每辆车离终点的距离为s[i],车长为l[i],速度为v[i],规定不能超车,问何时所有车都能过终点线 n<=1e5,保证 思路: #include<bit ...

  8. kvm无人值守安装centos6

    nginx配置 server { listen default_server; server_name _; root /home/iso; # Load configuration files fo ...

  9. 膜神犇 DPH

    神犇 DPH 让我写博客.但是,似乎我已经开始写了?!! I am young and naïve!!! Let us orz DPH! 上节课讲DFS,这个是我最擅长的.“暴力出奇迹”!

  10. scrapy原理

    scarpy据说是目前最强大的爬虫框架,没有之一.就是这么自信. 官网都是这么说的. An open source and collaborative framework for extracting ...