HDU-2100-lovekey

Source: Internet
Author: User

Lovekey


Time Limit: 3000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)

Total submission (s): 4638 accepted submission (s): 1491

Problem description The XYZ-26 hexadecimal number is a number in which each person is a capital letter. A, B, C ,... , X, y, and z represent 0 ~ 25 digits, the 26-digit number of an n-digit is converted into a 10-digit number. The rule is as follows:
A0a1a2a3... Each digit of An-1 represents a0a1a2a3... An-1, then the 10 hexadecimal value of the XYZ-26 number is

M = A0 * 26 ^ (n-1) + A1 * 26 ^ (n-2) +... + An-3*26 ^ 2 + an-2*26 + an-1

One day, Vivi suddenly played a romantic game. She wanted to hide in a school classroom and ask fengbing leaves to find them. Of course, she also knew that fengbing leaves were not luchi, so I found the shrimp of XYZ and the water prodigal son to help, they will write a XYZ-26 in the door of the VIVI classroom, respectively, A and B, respectively, and a password is set on the door lock. Obviously, the lock can be opened only when the password is found and the classroom can be smoothly entered. This set of passwords is called lovekey by members of XYZ. Fortunately, maple ice leaves know that lovekey is a 10 hexadecimal value and B 10 hexadecimal value and the XYZ-26 hexadecimal form. Of course, the shrimp and the water prodigal do not want to be difficult as maple ice leaves, so the number of digits of A and B will not exceed 200.
For example, the first group of test data
A = 0*26 ^ 5 + 0*26 ^ 4 + 0*26 ^ 3 + 0*26 ^ 2 + 3*26 + 7 = 85
B = 1*26 ^ 2 + 2*26 + 4 = 732
Then a + B = 817 = BFL

InputThere are multiple groups of test data.
Each group of test data contains two XYZ-26 numbers with both values, each of which contains only uppercase letters and each number must not exceed 200 characters.

OutputOutput The lovekey of XYZ. Each group of output occupies one row.

Sample Input

 
Aaaadh bcedrw uhdd aaaaa

Sample output

 
Bflxyzd

Code:

# Include "stdio. H "# include" string. H "int main () {char a [201], B [201], result [201]; int I, j, carry, Len; while (scanf ("% S % s", a, B )! = EOF) {memset (result, 'A', sizeof (result); // set the result array to 1, which is equivalent to 0 ~~ Strrev (a); strrev (B); // string reverse function if (strlen (a)> strlen (B) {Len = strlen (); for (I = strlen (B); I <Len; I ++) B [I] = 'a';} else {Len = strlen (B ); for (I = strlen (a); I <Len; I ++) A [I] = 'a';} carry = 0; for (I = 0; I <Len; I ++) // Add {result [I] = A [I] + B [I] + carry-'A '; if (result [I]> 'Z') {result [I]-= 26; carry = 1;} else {carry = 0 ;}} if (carry = 1) // process the last carry result [Len] = 'B'; for (I = Len; I> = 0; I --) // locate the subscript of the last digit if (result [I]! = 'A') {J = I; break;} For (; j> = 0; j --) // print printf ("% C ", result [J]); printf ("\ n");} return 0 ;}

I am confused when I am at 0, so B is the last bit to enter ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.