Lovekey

 1 import java.lang.*;
 2 import java.math.*;
 3 import java.util.*;
 4 import java.io.*;
 5 import java.lang.*;
 6 class Main
 7 {
 8     public static void main(String[] args)
 9     {
10         String a,b,c;
11         int i,len1,len2,len3;
12         BigInteger d[]=new BigInteger[201];
13         BigInteger s1,s2,s3;
14         BigInteger ox1=new BigInteger("0");
15         BigInteger ox2=new BigInteger("26");
16         Scanner cin=new Scanner(System.in);
17         d[0]=BigInteger.valueOf(1);
18         for(i=1;i<200;i++)
19         {
20             d[i]=d[i-1].multiply(BigInteger.valueOf(26));
21         }
22         while(cin.hasNext())
23         {
24             a=cin.next();
25             b=cin.next();
26             len1=a.length();
27             len2=b.length();
28             s1=BigInteger.valueOf(0);
29             s2=BigInteger.valueOf(0);
30             for(i=len1-1;i>=0;i--)
31             {
32                 s1=s1.add(BigInteger.valueOf(a.charAt(i)-'A').multiply(d[len1-i-1]));
33             }
34             for(i=len2-1;i>=0;i--)
35             {
36                 s2=s2.add(BigInteger.valueOf(b.charAt(i)-'A').multiply(d[len2-i-1]));
37             }
38             s3=s1.add(s2);
39             c="";
40             while(s3.compareTo(ox1)>0)
41             {
42                 c=c.concat(String.valueOf((char)(s3.mod(ox2).intValue()+'A')));
43                 s3=s3.divide(ox2);
44             }
45             len3=c.length();
46             for(i=len3-1;i>=0;i--)
47             {
48                 System.out.print(c.charAt(i));
49             }
50             System.out.println();
51         }
52     }
53 }

 

posted @ 2012-08-22 13:01  疼痛落在指尖  阅读(202)  评论(0编辑  收藏  举报