import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
public class Main
{
static Scanner c=new Scanner(System.in);
static BigInteger f(String s)
{
BigInteger t=BigInteger.valueOf(1);
BigInteger res=BigInteger.valueOf(0);
for(int i=s.length()-1;i>=0;--i)
{
int y=0;
char u=s.charAt(i);
if(u>='a'&&u<='z')
{
y=10+u-'a';
}
else
if(u>='A'&&u<='Z')
{
y=10+u-'A';
}
else y=u-'0';
res=res.add(BigInteger.valueOf(y).multiply(t));
t=t.multiply(BigInteger.valueOf(16));
}
return res;
}
public static void main(String args[]) throws IOException
{
String x,y;
while(c.hasNext())
{
x=c.next();
y=c.next();
BigInteger x1=f(x),x2=f(y);
System.out.println(x1.add(x2).toString());
}
}
}
Java BigInteger hdu 1720 为例
最新推荐文章于 2021-08-02 10:46:09 发布