HDU-1335 Basically Speaking
http://acm.hdu.edu.cn/showproblem.php?pid=1335
Basically Speaking
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1885 Accepted Submission(s): 729
Its buttons will include the capital letters A through F in addition to the digits 0 through 9.
It will support bases 2 through 16.
#include<stdio.h>
#include<string.h>
int cmp(int x,int y)
{
int s=,i;
for(i=;i<=y;i++)
s=s*x;
return s;
}
int main()
{
int t,n,s,l,i,r,j,k,p,q;
char str[];
int a[],b[];
while(~scanf("%s",str))
{
s=j=;
scanf("%d%d",&t,&n);
l=strlen(str);
for(i=;i<l;i++)
{
if(str[i]>=''&&str[i]<='')
a[j++]=str[i]-'';
else
a[j++]=str[i]-;
}
k=;
for(i=j-;i>=;i--)
{
r=a[i]*cmp(t,k);
s+=r;
k++;
}
q=;
while(s!=)
{
p=s%n;
b[q++]=p;
s=s/n;
}
for(j=;j<-q;j++)
{
if(q>)
break;
printf(" ");
}
for(i=q-;i>=;i--)
{
if(q>)
{
printf(" ERROR");
break;
}
if(b[i]==)
printf("A");
if(b[i]==)
printf("B");
if(b[i]==)
printf("C");
if(b[i]==)
printf("D");
if(b[i]==)
printf("E");
if(b[i]==)
printf("F");
if(b[i]>=&&b[i]<=)
printf("%d",b[i]);
}
printf("\n");
}
return ;
}
HDU-1335 Basically Speaking的更多相关文章
- HDU 1335 Basically Speaking(进制转换)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1335 Problem Description The Really Neato Calculator ...
- HDOJ 1335 Basically Speaking(进制转换)
Problem Description The Really Neato Calculator Company, Inc. has recently hired your team to help d ...
- Basically Speaking
Basically Speaking Time Limit: 2 Sec Memory Limit: 200 MB Submit: 19 Solved: 11 [Submit][Status][W ...
- HDU 1314 Numerically Speaking(大数加减乘除+另类二十六进制互相转换)
原题代号:HDU 1314 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1314 Numerically Speaking Time Limit: 2 ...
- ZOJ Problem Set - 1334 Basically Speaking ac代码及总结
这道题目不难,是一道简单的进制转换问题,但是发现了自己两个遗漏的知识点: 1.关于scanf (1)scanf函数在输入时是以回车或者空格作为一次输入的结束 (2)scanf函数在输入字符串的过程中是 ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
随机推荐
- tmux复制到windows剪贴板/粘贴板的坑
以下所有操作都是在windows下面用putty连接linux centos6的情景下. 一直很纳闷为什么在tmux模式下不能把复制到的文字放到系统的粘贴板里面呢?通过层层阻碍,终于找到了原因. 去掉 ...
- jquery 实现复选框单选
$(function() { $(':checkbox[name=复选框name值]').each(function() { $(this).click(function() { if ($(t ...
- (转载)delphi实例TDBGrid用右键菜单复制行粘贴行
delphi实例TDBGrid用右键菜单复制行粘贴行 这个从本质上来说就是DBGrid后台数据库的插入 右键复制当前行的相关数据到临时变量点粘贴时,覆盖数据或插入数据! db为数据库: 字段名id,n ...
- #Leet Code# Populating Next Right Pointers in Each Node II
描述:注意需要先self.connect(right)再self.connect(left),否则会有case通不过,原因是左边递归执行时依赖与右边的next已经建立,而先执行connect(left ...
- Custom template tags and filters
Code layout Custom template tags and filters must live inside a Django app. If they relate to an exi ...
- bss段为什么需要初始化?
我们都知道bss段需要初始化,但是这是为什么呢? 通过浏览资料,我们都会发现,bss段是不会出现在程序下载文件(*.bin *.hex)中的,因为全都是0.如果把它们出现在程序下载文件中,会增加程序下 ...
- App页面显示优化
在开发移动端APP页面时,对各操作系统各种型号的手机进行适配是必须的.然鹅,上周在开发完一个落地页后,被测试给打了回来,其中列出了一个在我看来很小的问题:单击进入页面的时候,页面还没加载完的时候字体显 ...
- 教你在你的应用程序中扩展使用dynamic类型
教你在你的应用程序中扩展使用dynamic类型 相信大家在开发中经常会接触到mvc中的ViewBag,有心的同学会,发现这就是一个dynamic类型,查看源码一谈究竟,本文也是根据dynamic来扩展 ...
- DM8168 解码显示模块代码阅读分析
解码/显示概述:从共享文件夹获取H264流,对264流进行解析,生成hdr文件,hdr文件中包含每一帧的信息,将视频帧信息存放在A8核分配的共享内存空间,供其他核或其他的link调用,M3 Video ...
- 深入探究JavaScript中的比较问题
先用最近遇到的几个问题做引子: 1 console.log(null==undefined); //true 2 console.log(null==false);//false 3 console. ...