zoj 1205 二十进制数相加

Martian Addition

Time Limit: 1 Second       Memory Limit: 32768 KB

  In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics. Every year, they would hold an Arithmetic Contest on Mars (ACM). The task of the contest is to calculate the sum of two 100-digit numbers, and the winner is the one who uses least time. This year they also invite people on Earth to join the contest.
  As the only delegate of Earth, you're sent to Mars to demonstrate the power of mankind. Fortunately you have taken your laptop computer with you which can help you do the job quickly. Now the remaining problem is only to write a short program to calculate the sum of 2 given numbers. However, before you begin to program, you remember that the Martians use a 20-based number system as they usually have 20 fingers. 

Input:
You're given several pairs of Martian numbers, each number on a line. 
Martian number consists of digits from 0 to 9, and lower case letters from a to j (lower case letters starting from a to present 10, 11, ..., 19). 
The length of the given number is never greater than 100.

Output:
For each pair of numbers, write the sum of the 2 numbers in a single line.

Sample Input:
1234567890 abcdefghij 99999jjjjj 9999900001

Sample Output:
bdfi02467j iiiij00000
ZOJ <wbr>1205 <wbr>Martian <wbr>Addition
ZOJ <wbr>1205 <wbr>Martian <wbr>Addition

   
#include < iostream >
#include
< map >
#include
< algorithm >
#include
< string >
using namespace std;

int main()
{
map
< char , int > char_int;
for ( int i = 0 ;i < 10 ;i ++ ){
char_int[
' 0 ' + i] = i;
}
for ( int i = 0 ; i < 10 ;i ++ ){
char ch = ' a ' ;
char_int[ch
+ i] = i + 10 ;
}

map
< int , char > int_char;
for ( int i = 0 ;i < 10 ;i ++ ){
int_char[i]
= ' 0 ' + i;
}
for ( int i = 0 ; i < 10 ;i ++ ){
char ch = ' a ' ;
int_char[i
+ 10 ] = ch + i;
}

string num1, num2 ,num3;
while (cin >> num1 >> num2){
reverse(num1.begin(),num1.end());
reverse(num2.begin(),num2.end());
int up = 0 ;
num3
= "" ;
string str;

if (num1.size() < num2.size()){
str
= num1;
num1
= num2;
num2
= str ;
}

for ( int i = 0 ;i < num2.size();i ++ ){
if (char_int[ num1[i] ] + char_int[num2[i]] + up >= 20 ){

num3
= int_char[char_int[ num1[i] ] + char_int[num2[i]] + up - 20 ] + num3;
up = 1 ;
}
else {

num3
= int_char[char_int[ num1[i] ] + char_int[num2[i]] + up] + num3;
up = 0 ;
}
}
if (up == 1 ){
for ( int i = num2.size();i < num1.size();i ++ ){
if (char_int[num1[i] ] + up >= 20 ){

num3
= int_char[char_int[num1[i]] + up - 20 ] + num3;
up
= 1 ;
}
else {

num3
= int_char[char_int[ num1[i] ]] + num3;
up
= 0 ;
}
}
}
else {
for ( int i = num2.size();i < num1.size();i ++ ){
num3
= int_char[char_int[ num1[i] ]] + num3;
}
}
if (up == 1 ){
num3
= ' 1 ' + num3;
}
cout
<< num3 << endl;
}
return 0 ;
}

转载于:https://www.cnblogs.com/laipDIDI/articles/2042894.html

嵌入式下载故障排查:ST-LINK与GD32 Programmer典型问题解决 嵌入式固件烧录是MCU开发的关键环节,其本质依赖于调试器(如ST-LINK、GD-Link)与目标芯片间的协议通信、驱动加载及硬件接口协同。原理上,SWD/JTAG协议需在正确时序、电平与供电条件下完成设备枚举、ID读取与Flash编程;技术价值在于保障量产烧录稳定性与调试可重复性;典型应用场景涵盖STM32/GD32教学开发、工业控制板量产调试及Windows 11新系统适配。本文聚焦ST-LINK-V2在Keil MDK中的下载失败和GD32 All In One Programmer的DLL加载异常两 阅读详情

相关推荐

SPSS篇—卡方检验

今天依旧跟大家分享一个在SPSS中使用率比较高的分析方法:卡方检验。 在开始做分析之前,我们需要明白两件事情:卡方检验是什么?一般用来干什么?我们只有充分了解分析方法以后才能够正确的使用它。 卡方检验在百科中的解释是:卡方检验是用途非常广的一种假设检验方法,它在分类资料统计推断中的应用,包括:两个率或两个构成比比较的卡方检验;多个率或多个构成比比较的卡方检验以及分类资料的相关分析等。它的原理是...

小白数据营的博客 20万+

保姆级教程:在Halcon中手把手实现高斯滤波,从原理到频域卷积操作详解

本文详细解析了在Halcon中实现高斯滤波的完整流程,从频域卷积的数学原理到工业视觉实战应用。通过`gen_gauss_filter`、`rft_generic`、`convol_fft`三大核心操作,实现高效图像去噪与边缘保留,特别适用于金属表面检测、PCB定位等高精度工业场景。

weixin_30632089的博客 501

代谢组学数据分析实战:用R语言从PCA、PLS-DA到OPLS-DA一步步搞定(附代码)

本文详细介绍了使用R语言进行代谢组学数据分析的全流程,从数据预处理到PCA、PLS-DA和OPLS-DA模型构建与验证。通过实际案例和代码示例,帮助研究者掌握关键分析技术,提升数据解读能力,特别适合生命科学领域的研究人员。

weixin_28689507的博客 133

ZOJ 1205: Martian Addition

20进制加法问题。 第一次没过,因为输出的时候忘记了考虑 0+0=0 的情况,被测试数据抓个正着 改掉这个bug就AC了 本来就是半路出家的学编程,不停的刷水题,结果每次都是代码写的也比较sloppy...  比单纯高精度稍微麻烦一点,难度系数=1 通过率数据 28.06% (5015/17869) import java.util.*; public class

业余程序员_专业吃货 1070

多目标进化算法——NSGA-II(python实现)

NSGA-II(python实现)--最全注释,痴呆能懂--

no___good的博客 5281

国网DLT698.45协议——采集系统、数据交换(一)

对于国网698协议,是一种面向对象的通信协议,用于远程监控和控制电力系统中的设备。面向对象使得对协议的思考更趋向于正常思维,使计算机中描述的抽象世界于现实世界中能够更好的对应起来。协议中就是将各种方法和属性对应描述成类和对象。接下来是我学习该协议的一些总结和认识,欢迎大家随时在评论区或者私信我交流学习。:系统=对象+消息:程序=算法+数据对象和接口类描述:类描述了一组具有相同属性和相同方法的对象。

一个bug是bug,多个bug能work 1万+

ZOJ_1205 Martian Addition

In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics. Every year, they would hold an Arithmetic Contest on Mars (ACM). The task

372

第67步 时间序列建模实战:ARIMA建模(Stata)

第67步 时间序列建模实战:ARIMA建模(Stata)

Jet4505的博客 6822

zoj 1205

给出两个字符串相加,20进制。注意的是同为0时要输出0;类似于da #include #include #include #include using namespace std; char stra[105],strb[110]; int main() {     memset(stra,'\0',sizeof(stra));     memset(strb,'\0'

学习之路 399

推荐系统[一]:超详细知识介绍,一份完整的入门指南,解答推荐系统相关算法流程、衡量指标和应用,以及如何使用jieba分词库进行相似推荐,业界广告推荐技术最新进展

推荐算法其实本质上是一种信息处理逻辑,当获取了用户与内容的信息之后,按照一定的逻辑处理信息后,产生推荐结果。热度排行榜就是最简单的一种推荐方法,它依赖的逻辑就是当一个内容被大多数用户喜欢,那大概率其他用户也会喜欢。但是基于粗放的推荐往往会不够精确,想要挖掘用户个性化的,小众化的兴趣,需要制定复杂的规则运算逻辑,并由机器完成。召回:当用户以及内容量比较大的时候,往往先通过召回策略,将百万量级的内容先缩小到百量级。

丨汀、的博客 7594

踩过20+工控视觉项目的坑后,我用C# + 海康相机 + YOLOv11实现了零依赖产线缺陷检测

触发式检测:只有光电传感器检测到零件到位,才触发相机拍照和算法检测,不是持续推理,减少工控机性能占用;全链路本地运行:从图像采集、算法推理到不良品剔除,所有逻辑全在本地工控机运行,不需要外网、不需要云端服务,哪怕产线断网也能正常运行;异常降级机制:算法推理异常时,系统自动触发产线缓停,同时声光告警,不会让不良品流到下工序,满足汽车行业IATF16949质量要求;模块化解耦:算法核心层和业务逻辑层完全分离,后续更换YOLO模型、新增缺陷类型,只需要替换模型文件,不需要修改业务逻辑;全链路可追溯。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 152

Python--ZOJ1205

Python--ZOJ1201

GuoJuXia的专栏 864

Python全栈入门到实战【JavaScript篇 15】async/await与Fetch API,打通前后端数据通道

Fetch API是浏览器内置的现代HTTP请求接口,用于向服务器发送请求并获取响应。它是(XHR)的替代品。学习Fetch的目标非常明确——用JS从后端API获取数据,并渲染到前端页面。这标志着前后端数据通道的打通,是实现全栈开发的核心技能。try {// 等待Promiseconst parallel = await Promise.all([ // 并行等待]);

那些看似不起波澜的日复一日,会在某天让你看到坚持的意义 1984

[ACM] ZOJ 1205

Martian AdditionTime Limit: 1 Second      Memory Limit: 32768 KB     In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics.

L's Space 1131

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Statistics and Machine Learning Toolbox

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

ZOJ 1205 二十进制相加

//////////////////////////////////////////////////////////////////Martian Addition//火星人(二十进制相加)#include<iostream>#include<string>using namespace std;char s1[105],s2[105];char chu[105]; ...

weixin_30778805的博客 70

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

ZOJ Problem Set - 1205 Martian Addition

Martian Addition Time Limit: 2 Seconds      Memory Limit: 65536 KB   In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics

acm_1361677193的专栏 379

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

ZOJ-1205* 二十进制加法

1205:计算两个二十进制数的和 Sample Input: 1234567890 abcdefghij 99999jjjjj 9999900001 Sample Output: bdfi02467j iiiij00000 值和字符间的转换关系 [code="c++"] int convertToInt(char src) { if(sr...

linest 186

zoj 1205 Martian Addition

题目意思很简单,两个数相加,按照二十进制的。。。。 看了别人的文章,发现了这题应该注意的地方: ~~~注意输出时要去掉前导零。。。 #include #include char str[105]; char getsum(char str1[],char str2[]) { int l,i,of,j,a,b,t; l=strlen(str1); of=0; for(i

YYlxid————Nothing is possible if not try~ 485

zoj_1205 Martian Addition

In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics. Every year, they would hold an Arithmetic Contest on Mars (ACM). The ta

I love Algorithm 561

zoj Martian Addition

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1205 同样是大整数加法的练手题目。题目意思就是:二十进制的大数相加,注意进位,注意字母和数字间的转换和都是零时有输出就可以了 1 #include<string.h> 2 #include<iostream> 3 #include<s...

weixin_30764883的博客 100

Martian Addition

FJNU.1865DescriptionIn the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics. Every year, they would hold an Arithmetic Contest o

linyq@BambooFan ~ 750

ZOJ 1205 Martian Addition

Martian Addition Time Limit: 2 Seconds      Memory Limit: 65536 KB   In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics

胖子加油! 428

ZOJ 1205 Martian Addition

In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics. Every year, they would hold an Arithmetic Contest on Mars (ACM). The t...

越努力,越幸运!!! 821

ZOJ Martian Addition (20进制的两个大数相加)

题目链接: #include &lt;cstdio&gt; #include &lt;cmath&gt; #include&lt;vector&gt; #include&lt;cstring&gt; #include&lt;algorithm&gt; #include&lt;cmath&gt; #include&lt;stack&gt; #include&lt;string&g

ZMST的博客 275

zoj1205-----------Martian Addition 大数处理

Martian Addition In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics. Every year, they would hold an Arithmetic Contest on Ma

Life is Float. 850
上一篇: zoj 2722 一次减少一半
下一篇: zoj 2736 水仙花
dinglangwei5539
博客等级 码龄11年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值