CODEFORCES:1B. Spreadsheets

本文详细解析了一种将Excel的row、column表示方式与RXCY表示方式之间进行切换的算法实现,包括R到E(Excel表示)与E到R(RXCY表示)的转换方法,以及如何通过字符区分输入数据属于哪种表示方式,同时解决特殊情况下的错误判断问题。

接着上次的说,我是在做这一题的时候才发现CODEFORCES上有submissions这一个选项,可以查看自己在哪一步出了错误;

接下来直接入主题,来看看这道题:

“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.”
简单地说,就是Excel的row,cloumn的表示方式与RXCY的表示方式的切换:
我的想法是:按输入的字符的不同类型去调用RtoE()与EtoR()方法,那么怎么能把他们区分开呢?例如:“R23C55“,”BC55“,怎么把它们分开呢?
我最初的想法是首先判断第一个是字符,第二个不是字符,那么就把它归为R的表示方法,然后调用RtoE()即可(注:上面出现的错误也说明这种方法有缺陷)
那么我的RtoE方法应该怎么写,想想,在这里我参考了 xujin的方法:
704%26=2-->B;

704/26=27;

27%26=1->A;

27/26=1;

1%26=1->A;

1/26=0;

此时c=0,结束循环

然后利用栈,倒着来输出。


注意到如果涉及到Z,就有点不同了。

如果余0,代表Z,然后令c--才是正确结果,

比如702代表ZZ,转换过程如下:

702%26=0-->Z;

704/26=27;

27--;

26%26=0->Z;

26/26=1;

1--;

此时c=0,结束循环
事实证明这个方法是行得通的:
private String RtoE(String s)          //RtoE方法将RXCY表示变化为Excel方法表示
	{
		byte ValueByte[] = s.getBytes();
		int i = 1;
		long pre = 0, next = 0;
		while(i < s.length() && ValueByte[i] != 'C')
		{
				i++;                          //使用i来保存'C'在字符串中的位置
		}
		String SubStrPre = s.substring(1, i);  
		String SubStrNext = s.substring(i+1);
		pre = Long.valueOf(SubStrPre);          //得到row
		next = Long.valueOf(SubStrNext);         //得到cloumn
		StringBuffer sb = new StringBuffer();
		int temple = 0;
		do
		{
			temple = (int)(next % 26);
			if(0 == temple)
			{
				sb.append('Z');
				next = next / 26;
				next--;
			}
			else
			{
				char ch = (char)('A' + temple - 1);
				sb.append(ch);
				next = next / 26;
			}
		}while(next != 0);
		StringBuffer bs = new StringBuffer(sb.reverse());      //使用bs得到sb的倒置
		return bs + String.valueOf(pre);                      //返回
	}

另外有一个EtoR这个比较简单,这里就不多说了:
private String EtoR(String s)
	{
		byte ValueByte[] = s.getBytes();
		int i = 1;
		while((ValueByte[i] >= 'A') && (ValueByte[i] <= 'Z') )
		{
			i++;                                 //用i记录输入字符串中的前面的字符的个数
		}
//		String SubStrPre = s.substring(0, i);
		String SubStrNext = s.substring(i);
//		System.out.println(s);
		long next = Long.valueOf(SubStrNext);            //得到row
		long pre = (long)(ValueByte[0] - 'A'+1);
		for(int j = 1; j < i; j++)
		{
//			System.out.println(ValueByte[j] - 'A'+1);
			pre = pre * 26 + (ValueByte[j] - 'A'+1);
//			System.out.println(pre);
		}                                                 //得到cloumn
		return 'R'+String.valueOf(next)+'C'+String.valueOf(pre);
	}

最后还有一点比较重要的要说,也是必须要说的:我在开头就给出了我的错误(我上面也说过了,我的判断方法有问题),即当他给出”A1“的时候,用上面的判断方法的话会调用RtoE,而事实上,它应该调用EtoR的方法,所以只好在判断时给出了特定情况,也就是第一个为字符,第二个不为字符,但后面也没有字符的话把它归类为E,应该调用EtoR:
public static void main(String[] args)
	{
		Spreadsheets ss = new Spreadsheets();
		Scanner in = new Scanner(System.in);
//		int num = in.nextInt();
		String test = in.nextLine();
		int num = Integer.valueOf(test);
		String str = new String();
		for(int i = 0; i < num; i++)
		{
			String s = in.nextLine();
			byte VB[] = s.getBytes();
			if(VB[1] <= '9' && VB[1] >'0')
			{
				boolean flag = false;
				for(int j = 1; j < VB.length; j++)
				{
					if(VB[j] > 'A' && VB[j] < 'Z')
						flag = true;
				}
				if(flag)
				{
					str = ss.RtoE(s);               //判断s为RXCY
				}
				else
				{
					str = ss.EtoR(s);               //判断s为Excel
				}
			}
			else
			{
				str = ss.EtoR(s);                   //判断s为Excel
			}
			System.out.println(str);
			str = new String();
		}
	}

那么这样就ok了



基于TROPOMI高光谱遥感仪器获取的大气成分观测资料,本研究聚焦于大气污染物一氧化氮(NO₂)的空间分布与浓度定量反演问题。NO₂作为影响空气质量的关键指标,其精确监测对环境保护与大气科学研究具有显著价值。当前,利用卫星遥感数据结合先进算法实现NO₂浓度的高精度反演已成为该领域的重要研究方向。 本研究构建了一套以深度学习为核心的技术框架,整合了来自TROPOMI仪器的光谱辐射信息、观测几何参数以及辅助气象数据,形成多维度特征数据集。该数据集充分融合了不同来源的观测信息,为深入解析大气中NO₂的时空变化规律提供了数据基础,有助于提升反演模型的准确性与环境预测的可靠性。 在模型架构方面,项目设计了一种多分支神经网络,用于分别处理光谱特征与气象特征等多模态数据。各分支通过独立学习提取代表性特征,并在深层网络中进行特征融合,从而综合利用不同数据的互补信息,显著提高了NO₂浓度反演的整体精度。这种多源信息融合策略有效增强了模型对复杂大气环境的表征能力。 研究过程涵盖了系统的数据处理流程。前期预处理包括辐射定标、噪声抑制及数据标准化等步骤,以保障输入特征的质量与一致性;后期处理则涉及模型输出的物理量转换与结果验证,确保反演结果符合实际大气浓度范围,提升数据的实用价值。 此外,本研究进一步对不同功能区域(如城市建成区、工业带、郊区及自然背景区)的NO₂浓度分布进行了对比分析,揭示了人类活动与污染物空间格局的关联性。相关结论可为区域环境规划、污染管控政策的制定提供科学依据,助力大气环境治理与公共健康保护。 综上所述,本研究通过融合TROPOMI高光谱数据与多模态特征深度学习技术,发展了一套高效、准确的大气NO₂浓度遥感反演方法,不仅提升了卫星大气监测的技术水平,也为环境管理与决策支持提供了重要的技术工具。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值