hdu 2106 decimal system
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 1000
using namespace std;
char str[maxn]; int change(char *s)
{
int k=strlen(s);
int pos;
int sum=;
for(int i=; i<k; i++)
{
if(s[i]=='(')
{
pos=i;
break;
}
}
int m;
if(s[pos+]=='')
{
m=;
}
else
m=s[pos+]-'';
int j=;
for(int i=pos-; i>=; i--)
{
sum+=(s[i]-'')*pow(m,j);
j++;
}
return sum;
} int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int sum1=;
for(int i=; i<n; i++)
{
scanf("%s",str);
sum1+=change(str);
}
printf("%d\n",sum1);
}
return ;
}
hdu 2106 decimal system的更多相关文章
- HDOJ(HDU) 2106 decimal system(进制相互转换问题)
Problem Description As we know , we always use the decimal system in our common life, even using the ...
- HDU 2106 decimal system (进制转化求和)
题意:给你n个r进制数,让你求和. 析:思路就是先转化成十进制,再加和. 代码如下: #include <iostream> #include <cstdio> #includ ...
- 十进制(decimal system)转换函数说明
一,十进制(decimal system)转换函数说明 1,十进制转二进制 decbin() 函数,如下实例 echo decbin(12); //输出 1100 echo decbin(26); / ...
- hdu 2106
#include <iostream> #include <cmath> #include <string.h> using namespace std; int ...
- decimal system 2016
Problem Description As we know , we always use the decimal system in our common life, even using the ...
- 杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》
http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2 1.2.5 #include<stdio.h> ...
- HDU 3072 Intelligence System (强连通分量)
Intelligence System Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 1690 Bus System(Dijkstra最短路)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1690 Bus System Time Limit: 2000/1000 MS (Java/Others ...
- HDU 4744 Starloop System(ZKW费用流)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4744 题意:三维空间n个点,每个点有一个wi值.每对点的距离定义为floor(欧拉距离),每对点之间建 ...
随机推荐
- HDOJ 1330 Deck(叠木块-物理题啊!贪心算法用到了一点)
Problem Description A single playing card can be placed on a table, carefully, so that the short edg ...
- 算法导论(第三版)Exercises2.3(归并排序、二分查找、计算集合中是否有和为X的2个元素)
2.3-1: 3 9 26 38 41 49 52 59 3 26 41 52 9 38 49 57 3 41 52 26 38 57 9 49 3 41 52 26 38 ...
- linux0.12 学习总序(不断更新状态中)
最近有空闲时间,想静下心来学点东西.一直对kernel有兴趣,又苦于无从下手,就拿linux0.12练手.尝试了解并熟悉kernel各模块工作原理. 接下来的博客主要用来记录自己所遇到的问题和解决的方 ...
- java实现的23种设计模式 (个人推荐)
http://zz563143188.iteye.com/blog/1847029 mark下,个人用,大家会也可以看看写的不错.
- IP地址分类及特殊IP地址
A类:0xxx xxxx.x.x.x/8,即1~127,共126个可用. 因0.x.x.x表示所有网络:127.x.x.x/8用作回环地址,作为测试TCP/IP协议的地址. =>其中10.x.x ...
- Spring的StringUtils工具类
本文是转载文章,感觉比较好,如有侵权,请联系本人,我将及时删除. 原文网址:<Spring的StringUtils工具类> org.springframework.util.StringU ...
- javascript 缓冲运动demo
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- (转)Linux bash shell脚本语法入门
http://www.linuxsky.org/doc/newbie/201004/389.html 1.基础 #!/bin/bash //bash脚本第一句都是这个,他会让系统指定以bash来解释这 ...
- lesson4:利用jmeter来压测数据库
本文讲述了如何利用jmeter来压测数据库,事例中选取了mysql作为测试数据库,其它的数据库也是一样,只需要更换驱动程序即可. 准备工作:a.mysql数据库安装,请自行百度:b.jdbc驱动包,请 ...
- 你需要知道的九大排序算法【Python实现】之归并排序
四.归并排序 基本思想:归并(Merge)排序法是将两个(或两个以上)有序表合并成一个新的有序表,即把待排序序列分为若干个子序列,每个子序列是有序的.然后再把有序子序列合并为整体有序序列.归并过程:比 ...