joj1006

本文介绍了一个关于进制转换及加法的问题:给定一个进制和两个十进制数,将这两个数转换为指定进制并进行相加运算,最后输出其和。文章通过示例解释了如何在不同进制下进行数值转换和加法操作。
   

1006: All your base


ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE
3s8192K57931915Standard

Given a base, and two positive integers in decimal (base 10), convert the two numbers to the new base, add them, and display their sum in the new base.

Input

Three positive integers denoting the base and the two numbers, respectively. Input numbers will be integers between 0 and 65535. Bases will be between 2 and 10 inclusive. Each case will be on a separate line. The end of input will be denoted by three zeros.

Output

An equation for the sum of the two numbers, in the new base.

Example

In this example, we add 10 and 3 in base 2, and we add 15 and 4 in base 3.

In base 2, 10 = 8 + 2 = 1*23 + 0*22 + 1*21 + 0*20 and 3 = 2 + 1 = 1*21 + 1*20, so their base 2 equivalents are 1010 and 11, respectively. 10 + 3 = 13 = 1*23+1*22+0*21+1*20, so the base 2 equivalent of 13 is 1101.

In base 3, 15 = 9 + 6 = 1*32+2*31+0*30 and 4 = 3 + 1 = 1*31 + 1*30, so their base 2 equivalents are 120 and 11, respectively. 15 + 4 = 19 = 2*32 + 0*31 + 1*30, so the base 3 equivalent of 19 is 201.

Input

2 10 3
3 15 4
0 0 0

Output

1010 + 11 = 1101
120 + 11 = 201
'


This problem is used for contest: 53  167  181  184 


Submit / Problem List / Status / Discuss


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值