2013
12-29

# decimal system

As we know , we always use the decimal system in our common life, even using the computer. If we want to calculate the value that 3 plus 9, we just import 3 and 9.after calculation of computer, we will get the result of 12.
But after learning <<The Principle Of Computer>>,we know that the computer will do the calculation as the following steps:
1 computer change the 3 into binary formality like 11;
2 computer change the 9 into binary formality like 1001;
3 computer plus the two number and get the result 1100;
4 computer change the result into decimal formality like 12;
5 computer export the result;

In the computer system there are other formalities to deal with the number such as hexadecimal. Now I will give several number with a kind of change method, for example, if I give you 1011(2), it means 1011 is a number in the binary system, and 123(10) means 123 if a number in the decimal system. Now I will give you some numbers with any kind of system, you guys should tell me the sum of the number in the decimal system.

There will be several cases. The first line of each case contains one integers N, and N means there will be N numbers to import, then there will be N numbers at the next N lines, each line contains a number with such form : X1….Xn.(Y), and 0<=Xi<Y, 1<Y<=10. I promise you that the sum will not exceed the 100000000, and there will be at most 100 cases and the 0<N<=1000.

There will be several cases. The first line of each case contains one integers N, and N means there will be N numbers to import, then there will be N numbers at the next N lines, each line contains a number with such form : X1….Xn.(Y), and 0<=Xi<Y, 1<Y<=10. I promise you that the sum will not exceed the 100000000, and there will be at most 100 cases and the 0<N<=1000.

3
1(2)
2(3)
3(4)

4
11(10)
11(2)
11(3)
11(4)

6
23

http://acm.hdu.edu.cn/showproblem.php?pid=2106

#include <stdio.h>
#include <string.h>

long pows(int a,int b)
{
int i;
long sum = 1;
for (i=0;i<b;i++)
{
sum=sum*a;
}
return sum;
}

int main()
{
int D;
char Num[50];
int NumOfTest;
char strings[50];
int i,j,k,len,t,g;
long sum;
/*freopen("e://1.txt","r",stdin);*/
while (scanf("%d",&NumOfTest)!=EOF)
{
sum = 0;
for (i=0;i<NumOfTest;i++)
{
scanf("%s",strings);
j=0;
k=0;
D = 0;
while (strings[j]!='(')
{
Num[k] = strings[j];
k++;
j++;
}
Num[k] = '/0';
j++;
while (strings[j]!=')')
{
D = D*10+(strings[j]-'0');
j++;
}
len =strlen(Num);
k = len-1;
for (j=0;j<len;j++)
{
g=Num[j]-'0';
t = pows(D,k);
sum+=(g*t);
k--;
}
}
printf("%ld/n",sum);
}
return 0;
}

1. for(int i=1; i<=m; i++){
for(int j=1; j<=n; j++){
dp = dp [j-1] + 1;
if(s1.charAt(i-1) == s3.charAt(i+j-1))
dp = dp[i-1] + 1;
if(s2.charAt(j-1) == s3.charAt(i+j-1))
dp = Math.max(dp [j - 1] + 1, dp );
}
}
这里的代码似乎有点问题？ dp(i)(j) = dp(i)(j-1) + 1;这个例子System.out.println(ils.isInterleave("aa","dbbca", "aadbbcb"));返回的应该是false

2. 第一句可以忽略不计了吧。从第二句开始分析，说明这个花色下的所有牌都会在其它里面出现，那么还剩下♠️和♦️。第三句，可以排除2和7，因为在两种花色里有。现在是第四句，因为♠️还剩下多个，只有是♦️B才能知道答案。