【优化】Codeforces Beta Round #1 / 1B Spreadsheets (字符串处理)

codeforces-1B. Spreadsheets 1B. Spreadsheets 阅读详情

B. Spreadsheets
time limit per test
10 seconds
memory limit per test
64 megabytes
input
standard input
output
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.

Input

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 .

Output

Write n lines, each line should contain a cell coordinates in the other numeration system.

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55

比较下下面两个代码的不同之处~


完整代码:

/*186ms,0KB*/

#include<cstdio>
#include<cstring>
#include<cstdlib>

char str[17], col[8];

int main()
{
	int n, c, temp;
	bool hasc;
	scanf("%d", &n);
	while (n--)
	{
		memset(str, 0, sizeof(str));
		memset(col, 0, sizeof(col));
		scanf("%s", str);
		int len = strlen(str), i = 2, j = 0;
		hasc = false;
		for (; i < len; ++i) ///从2开始找'C'
		{
			if (str[i] == 'C')
			{
				if (str[i - 1] >= '0' && str[i - 1] <= '9')
					hasc = true;
				break;
			}
		}
		if (hasc) ///RXCY格式 转 字母+数字格式
		{
			///提取colnum
			for (j = i + 1; j < len; ++j)
				col[j - i - 1] = str[j];
			c = atoi(col);///#include<cstdlib>
			///10进制转26进制,最后逆序输出
			memset(col, 0, sizeof(col));
			j = 0;
			while (c > 26)
			{
				temp = c % 26;
				if (temp == 0)
					temp = 26;
				col[j++] = '@' + temp;
				c = (c - temp) / 26;
			}
			col[j] = '@' + c;
			for (; j >= 0; --j)
				printf("%c", col[j]);
			for (j = 1; j < i; ++j)
				printf("%c", str[j]);
		}
		else///字母+数字格式 转 RXCY格式
		{
			putchar('R');
			for (; str[j] > '@'; ++j)
				;
			temp = j - 1;
			for (; j < len; ++j)
				printf("%c", str[j]);
			putchar('C');
			c = 0;
			for (int index = 1; temp >= 0; --temp, index *= 26)
				c += (str[temp] - '@') * index;
			printf("%d", c);
		}
		printf("\n");
	}
	return 0;
}


更快的代码:

/*46ms,0KB*/

#include <cstdio>

char s[15], c;

int num(int b, int l)
{
	int temp = 0;
	for (int i = b; i < l; ++i)
		temp = temp * 10 + s[i] - '0';
	return temp;
}

int pow(int x, int y)
{
	int temp = 1;
	for (int i = 0; i < y; ++i)
		temp *= x;
	return temp;
}

int main()
{
	int n;
	scanf("%d\n", &n);
	while (n--)
	{
		int l = 0, f = 0;
		while ((c = getchar()) != '\n')
		{
			s[l++] = c;
			if (s[l - 2] >= '0' && s[l - 2] <= '9' && c > '9')
				f = l - 1;
		}
		if (f)
		{
			int temp = num(f + 1, l);
			l = f;
			while (temp > 0)
			{
				c = temp % 26 + '@';
				if (c == '@')
				{
					--temp;
					c = 'Z';
				}
				s[++l] = c;
				temp /= 26;
			}
			for (int i = l; i > f; --i)
				putchar(s[i]);
			for (int i = 1; i < f; ++i)
				putchar(s[i]);
			putchar('\n');
		}
		else
		{
			putchar('R');
			while (s[++f] > '9');
			for (int i = f; i < l; ++i)
				putchar(s[i]);
			int temp = 0;
			for (int i = 0; i < f; ++i)
				temp += (s[i] - '@') * pow(26, f - i - 1);
			printf("C%d", temp);
			putchar('\n');
		}
	}
	return 0;
}



spreadsheet-api Formula One ActiveXspreadsheet-api-and-engine.pdf 立即下载

相关推荐

libero烧录信号抓取

提示:如果改了东西需要重新烧录,需要把这两个界面都关闭再libero打开。两个红色的要关闭掉。然后返回libero开始烧录,观测信号(如果只烧录观测从这一步开始就行)等到下面的messige出现以下信息表示run好了。在下图中右侧可以自己设置,设置完之后记得保存一下。run一下,耐心等待,有警告就ok,run完之后。run成功会变绿色,然后点下面的这个看波形。设置抓取信号:在libero打开。打开的就是烧录界面,直接run。

qq_34047965的博客 1421

Codeforces #1B Spreadsheet

一.问题描述:  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 mar...

RTR 349

用ESP32-S3+OV2640摄像头+ILI9488屏,DIY一个能联网的智能猫眼(附完整代码)

本文详细介绍了如何利用ESP32-S3微控制器搭配OV2640摄像头和ILI9488显示屏,DIY一个功能强大的智能猫眼系统。从硬件选型、电路设计到软件开发,提供了完整的解决方案和优化技巧,包括图像采集显示、WiFi远程访问及低功耗设计,适合智能家居爱好者动手实践。

weixin_30897233的博客 501

B. Spreadsheets

time limit per test 10 seconds memory limit per test 64 megabytes input standard input output standard output In the popular spreadsheets systems (for example, in Excel) the

无知的我 3000

如何下载era5数据?(两种方式)

供水利大数据云计算课程同学参考使用#

Camiel_sweet的博客 1万+

PyTorch版Unet训练后别只看loss:手把手教你计算并可视化多类别语义分割的mIoU(附完整代码)

本文详细介绍了在PyTorch中使用Unet模型进行多类别语义分割后,如何计算和可视化mIoU(mean Intersection over Union)以全面评估模型性能。通过完整的代码示例和实用技巧,帮助开发者从loss优化转向更精准的区域分割评估,特别适用于医学图像分析等关键场景。

weixin_30906185的博客 435

行列转换

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

hyesuixin的博客 498

宇树G1二次开发资料汇总

宇树科技G1是一款29自由度的商业级人形机器人,配备NVIDIA Jetson Orin NX计算平台和完整SDK生态。本文系统介绍了G1的硬件架构、29个关节配置、传感器外设、双计算单元设计等关键信息,并详细解析了软件生态体系,包括C++/Python SDK、ROS2接口、仿真工具和AI框架。开发者可通过DDS通信实现高层运动控制或底层关节级精确控制,支持快速二次开发。文档提供了网络配置、接口调用示例等实用指南,帮助开发者高效利用该平台进行人形机器人应用开发。

m0_47999117的博客 1313

Spreadsheet(翻译)

2022.1.18 题目网址: https://acs.jxnu.edu.cn/problem/CF1B 原题: Spreadsheet 10000ms65536K 描述: 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, ...

qq_61768389的博客 349

SAP 系统里生成 PDF 的几条主干路径:从 Spool 转换到 Adobe 原生渲染,再到 BTP 云服务

本文系统梳理了SAP生态中PDF生成的多种技术方案,包括Spool转换、OTF转换、Smart Forms/Adobe Forms原生生成以及云端服务等不同路径。文章通过实际案例和代码示例,详细分析了各方案的适用场景、技术要点和工程实践建议,特别强调了多语言支持、字体处理、性能优化等关键因素。针对不同业务需求,提供了从简单导出到复杂交互式PDF的完整解决方案框架,为SAP环境下的PDF处理提供了实用指南。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 285

基于信号完整性的PCB设计原则

基于信号完整性的PCB设计建议,以单网络的信号布线作为评估对象,给出了一些最基础的设计指导,如何灵活运用,取决于设计者根据实际场景如何做取舍和判断。

一只豌豆象的博客 1758

Codeforces 1B. Spreadsheets

【题目来源】:点击打开链接【题目描述】: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 t...

mcp3128 493

从零开始玩转边缘 AI:Jetson Nano 深度学习环境搭建与 YOLOv5 部署指南

Jetson Nano是NVIDIA推出的嵌入式AI开发板,凭借其强大的GPU计算能力和完善的软件生态系统,成为边缘AI部署的理想平台。本教程源于作者团队参加2024中国机器人大赛暨RoboCup机器人世界杯中国赛机器人先进视觉3D识别赛道的实战经验,是一份经过验证的环境部署指南。

LXY_LOVE36的博客 234

Codeforces 1B.Spreadsheets

1 题目描述(题目链接) 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 2

qq_39378221的博客 345

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

训练-777-111

A - Spreadsheets CodeForces - 1B In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the seco...

weixin_30445169的博客 287

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

1B. Spreadsheets

B. Spreadsheets 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: colum

qq_39765898的博客 248

文章标题 CoderForces 1B : Spreadsheets(模拟)

SpreadsheetsDescription 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

Wang_SF2015的博客 478

CodeForces 1B Spreadsheets(模拟)

B. Spreadsheets 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 colu

nudt_oys的博客 646

B - Spreadsheet(进制转换+字符串大模拟)

B. Spreadsheets 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 ...

一只小蒟蒻的博客 787

http://codeforces.com/contest/1/problem/B

B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard input output standard output In the popular spreadsheets systems (for example, in Excel) the following

sdjzqing的专栏 778

Day 16 B. Spreadsheets

Problem: 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 ha

Jackey_tao的博客 252

1.18 Spreadsheet

描述: 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 nu

Zhouwen_的博客 302

Spreadsheet

描述: 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 nu

Liuxf的博客 249

利用sprintf和sscanf实现十六进制和十进制之间的相互转换(转载)

( 在日常应用过程中,经常遇到二进制转换的问题,正好看到有这个非常简单的转换方法,记录下来,方便以后使用。) #include <stdio.h> int main() { char s[100] = {0}; sprintf(s, "%x", 15); printf("%s\n", s); // f char str[100] = "f"; int i = 0; sscanf(str, "%x", &i); printf("%d\n", i); // 15

博客 932

一个例子告诉你使用sscanf将十六进制字符串转换成二进制值

【代码】一个例子(带输出结果)告诉你使用sscanf将十六进制字符串转换成二进制值的方法。

845
上一篇: Codeforces Beta Round #98 (Div. 2) / 137A Postcards and photos (模拟)
下一篇: 编程中无穷大常量的设定技巧
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值