1007 Number Converter
来源:互联网 发布:heroku自定义域名 编辑:程序博客网 时间:2024/05/17 09:06
1007 Number Converter
Number Converter
时间限制: 1秒 内存限制: 64M
Problem Description
As we know 3 = 11 if we think about the binary representation . Now let’s make a number converter. Given you two integers n (0 <= n <=10^9) and k (2 <= k <= 36), please output the representation of the n in the radix specified by k. And in the representation, you should use A, B, … to represent 10, 11, …
Input
This problem contains multiple test cases.
For each test case, there are two integers n and k.
Output
For each test case, please output the representation of the n in the radix specified by k.
Sample Input
3 2
4 3
15 16
Sample Output
11
11
F
一开始交上去之后就出现了re,找了半天才发现是二进制的问题,忘记了二进制数字非常长的特点
方法很简单,短除取余,仅此而已
- #include<stdio.h>
- #include<string.h>
- //#define input (freopen("text.txt","r",stdin));
- int main()
- {
- //input;
- char ch[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0";//最后的0是由于误认为是数组下标越界造成re而加上的,应该没用
- char ans[60];//(10^9)2 == 111011100110101100101000000000,共30位
- int i, n, k;
- while ( scanf("%d%d",&n,&k) != -1 )
- {
- memset(ans,0,sizeof(ans));
- i = 54;
- do{
- ans[i] = ch[n%k];
- n /= k;
- i --;
- }while( n );
- printf("%s\n",(ans + i + 1));
- }
- return 0;
- }
- 1007 Number Converter
- BIT 1007 Number Converter
- 寒假练习 1007 Number Converter
- 2013寒假练习 1007:Number Converter
- BIT1007 Number Converter
- bit Number Converter
- JSF转换器(converter),数字(number)
- BIT寒假练习-2013__1007:Number Converter
- Converter
- Converter
- Converter
- Converter Tutorial
- ASCII Converter
- Android Retrofit 2.0自定义Converter(JSONObject Converter)
- HTML to XHTML Converter
- Acme CAD Converter 6.8
- VBto Converter 2.14
- assignment 2 - temperature converter
- MySQL行锁深入研究
- Freemarker+Flying sauser +Itext 整合生成PDF
- webpy中配置发送邮件服务
- hciattach 分析
- ip地址检查正则表达式 兼容ipv4,ipv6
- 1007 Number Converter
- When Should Your Business Consider Data Center Outsourcing?
- MyISAM 和 InnoDB 讲解
- 单页设计艺术
- 让自己的Launcher成为系统中的唯一
- Win32的程序框架(VC6.0)
- iphone开发常用代码
- boa 流程分析
- mysql查询语句优化