hdoj 1877 又一版 A+B (进制问题)
来源:互联网 发布:云计算前景200字分析 编辑:程序博客网 时间:2024/05/18 02:42
/*
又一版 A+B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 13275 Accepted Submission(s): 5055
Problem Description
输入两个不超过整型定义的非负10进制整数A和B(<=231-1),输出A+B的m (1 < m <10)进制数。
Input
输入格式:测试输入包含若干测试用例。每个测试用例占一行,给出m和A,B的值。
当m为0时输入结束。
Output
输出格式:每个测试用例的输出占一行,输出A+B的m进制数。
Sample Input
8 1300 48
2 1 7
0
Sample Output
2504
1000
Author
ZJU
Source
浙大计算机研究生复试上机考试-2008年
Recommend
We have carefully selected several similar problems for you: 1878 1879 1880 1881 1230
#include<cstring>
#include<stdlib.h>
#define M 10000
int c[M];
int main()
{
int m;
while(scanf("%d",&m),m)
{
memset(c,0,sizeof(c));
int a,b,i=0,count=0;
scanf("%d%d",&a,&b);
__int64 sum=a+b;
if(sum==0)//0的任何进制结果都应该为0;
printf("0");
else
{
while(sum)
{
c[count++]=sum%m;
sum/=m;
}
for(i=count-1;i>=0;i--)
printf("%d",c[i]);
}
printf("\n");
}
return 0;
}
又一版 A+B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 13275 Accepted Submission(s): 5055
Problem Description
输入两个不超过整型定义的非负10进制整数A和B(<=231-1),输出A+B的m (1 < m <10)进制数。
Input
输入格式:测试输入包含若干测试用例。每个测试用例占一行,给出m和A,B的值。
当m为0时输入结束。
Output
输出格式:每个测试用例的输出占一行,输出A+B的m进制数。
Sample Input
8 1300 48
2 1 7
0
Sample Output
2504
1000
Author
ZJU
Source
浙大计算机研究生复试上机考试-2008年
Recommend
We have carefully selected several similar problems for you: 1878 1879 1880 1881 1230
*/
#include<cstdio>#include<cstring>
#include<stdlib.h>
#define M 10000
int c[M];
int main()
{
int m;
while(scanf("%d",&m),m)
{
memset(c,0,sizeof(c));
int a,b,i=0,count=0;
scanf("%d%d",&a,&b);
__int64 sum=a+b;
if(sum==0)//0的任何进制结果都应该为0;
printf("0");
else
{
while(sum)
{
c[count++]=sum%m;
sum/=m;
}
for(i=count-1;i>=0;i--)
printf("%d",c[i]);
}
printf("\n");
}
return 0;
}
0 0
- hdoj 1877 又一版 A+B (进制问题)
- HDOJ 1877 又一版 A+B(进制转换,水)
- HDOJ 1877 又一版 A+B 【进制转换】
- hdoj 1877 又一版 A+B 【进制转换】
- hdoj.1877 又一版 A+B 20140804
- hdoj 1877 又一版 A+B
- HDOJ 1877-又一版 A+B
- HDOJ 1877 又一版 A+B
- hdoj又一版A+B
- (ZJU-2008复试)-HDOJ-1877-又一版 A+B
- hdoj 1877 又一版 A+B 水过~
- hdoj 又一版 A+B 1877 (机制转换)
- hdoj--1877--又一版 A+B(水题)
- HDOJ(HDU) 1877 又一版 A+B(进制、、)
- hdoj 1032 又一版 A+B
- HDU 1877 又一版 A+B(进制转换)
- 又一版 A+B 1877
- 问题 A: 又一版 A+B
- MFC执行顺序
- python使用PIL处理图片的一些收获和经验
- 当时德国
- 二叉树所有根到叶子节点路径打印
- 安卓开发中Android消息机制详解
- hdoj 1877 又一版 A+B (进制问题)
- 0起步的摄影初学笔记
- ym——Android开发编码规范
- Android Volley完全解析(一),初识Volley的基本用法
- Android Volley完全解析(二),使用Volley加载网络图片
- deep learning 自学习网络的Softmax分类器
- Android Volley完全解析(三),定制自己的Request
- 10.10 Yosemite
- 查看电脑CPU是否支持VT虚拟化的几个软件