PAT.A1100 Mars Numbers

本文介绍了一种将地球上的十进制数字转换为火星上十三进制数字的算法,并提供了相应的程序实现。通过该程序,可以实现地球数字与火星数字之间的相互转换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

People on Mars count their numbers with base 13:

  • Zero on Earth is called "tret" on Mars.
  • The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec" on Mars, respectively.
  • For the next higher digit, Mars people name the 12 numbers as "tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou", respectively.

For examples, the number 29 on Earth is called "hel mar" on Mars; and "elo nov" on Mars corresponds to 115 on Earth. In order to help communication between people from these two planets, you are supposed to write a program for mutual translation between Earth and Mars number systems.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive integer N (< 100). Then N lines follow, each contains a number in [0, 169), given either in the form of an Earth number, or that of Mars.

Output Specification:

For each number, print in a line the corresponding number in the other language.

Sample Input:

4
29
5
elo nov
tam

Sample Output:

hel mar
may
115
13
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<utility>
using namespace std;

int main() {
	string unitd[13] = { "tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec" };
	string tend[13] = { "tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou" };
	map<string, int> huo2;
	huo2.insert(pair<string, int>("tret", 0));
	huo2.insert(pair<string, int>("jan", 1));
	huo2.insert(make_pair("feb", 2));
	huo2.insert(pair<string, int>("mar", 3));
	huo2.insert(pair<string, int>("apr", 4));
	huo2.insert(pair<string, int>("may", 5));
	huo2.insert(pair<string, int>("jun", 6));
	huo2.insert(pair<string, int>("jly", 7));
	huo2.insert(pair<string, int>("aug", 8));
	huo2.insert(pair<string, int>("sep", 9));
	huo2.insert(pair<string, int>("oct", 10));
	huo2.insert(pair<string, int>("nov", 11));
	huo2.insert(pair<string, int>("dec", 12));
	huo2.insert(pair<string, int>("tam", 13));
	huo2.insert(pair<string, int>("hel", 26));
	huo2.insert(pair<string, int>("maa", 39));
	huo2.insert(pair<string, int>("huh", 52));
	huo2.insert(pair<string, int>("tou", 65));
	huo2.insert(pair<string, int>("kes", 78));
	huo2.insert(pair<string, int>("hei", 91));
	huo2.insert(pair<string, int>("elo", 104));
	huo2.insert(pair<string, int>("syy", 117));
	huo2.insert(pair<string, int>("lok", 130));
	huo2.insert(pair<string, int>("mer", 143));
	huo2.insert(pair<string, int>("jou", 156));
	int n;
	cin >> n;
	getchar();
	while (n--) {
		string huo;
		getline(cin, huo);
		if (huo[0] >= '0'&&huo[0] <= '9') {
			int l = huo.length(), d = 0;
			for (int i = 0; i < l; i++) {
				d = d * 10 + (huo[i] - '0');
			}
			if (d / 13 > 0 && d % 13 != 0) {
				cout << tend[d / 13] << " " << unitd[d % 13] << "\n";
			}
			else if (d / 13 == 0)
				cout << unitd[d % 13] << "\n";
			else
				cout << tend[d / 13] << "\n";

		}
		else {
			int d = 0;
			if (huo == "tret") d = 0;
			else if (huo.length() > 3) {
				//cout << "sds  ";
				map<string, int>::iterator it = huo2.find(huo.substr(0, 3));
				d = it->second;
				it = huo2.find(huo.substr(4, 3));
				d += it->second;
			}
			else {
				//cout << "swewr  ";
				map<string, int>::iterator it = huo2.find(huo);
				d = it->second;
			}
			cout << d << "\n";
		}
	}


	return 0;
}

内容概要:本文详细介绍了深度学习的基本概念和技术要点,涵盖了从基础知识到高级模型的多个方面。首先,文中强调了激活函数与权重初始化的最佳实践,如ReLU搭配He初始化,Sigmoid或Tanh搭配Xavier初始化。接着,文章系统地讲解了深度学习所需的数学基础(线性代数、微积分、概率统计)、编程技能(Python、PyTorch/TensorFlow)以及机器学习基础(监督学习、无监督学习、常见算法)。此外,还深入探讨了神经网络的核心组件,包括前向传播、反向传播、激活函数、优化算法、正则化方法等,并特别介绍了卷积神经网络(CNN)、循环神经网络(RNN)、长短期记忆网络(LSTM)、注意力机制(Attention)、Transformer架构及其衍生模型(BERT、GPT)。最后,文章讨论了大模型训练、分布式训练、模型压缩、Prompt Engineering、文本生成、多模态学习等前沿话题,并提供了学习资源推荐。 适合人群:对深度学习有一定兴趣并希望深入了解其原理的研究人员、工程师或学生,尤其是那些具备一定编程基础和数学知识的人群。 使用场景及目标:①帮助读者理解深度学习中的关键概念和技术细节;②指导读者如何选择合适的激活函数和权重初始化方法;③为读者提供构建和优化神经网络模型的实际操作指南;④介绍最新的研究进展和发展趋势,拓宽读者视野。 其他说明:建议读者在学习过程中结合实际案例进行练习,积极尝试文中提到的各种技术和工具,同时关注领域内的最新研究成果,以便更好地掌握深度学习的应用技巧。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值