2001 LSU Computer Science High School Programming Contest

Sponsored by Texas Instruments

Veteran - Problem 6

 MAIN
  Home
  Schedule
  Registration
  Rules
  About
  Language
  
 RESULTS
  Standings
  Problem Set
  
 LINKS
  LSU
  Computer Science
  Contest Index
  HS 2000
  ACM Intl PC
  PC2
  
 THANKS
  Sponsor
  Schools
  Volunteers
 

Wild, Wacky, and Weird Math

Problem: Like any math professor, Dr. StrangeMath loves to do math problems. Unfortunately, this individual has a strange way of writing down math problems. He doesn't write numbers the same way everyone else does. When he designs problems for a test, he doesn't put the problems and the answers on the same page for his key. He writes down the problems in a special code and writes down the answers in a normal manner. His assistant, Egor Van Strautiovich always double-checked the prof.'s strange work -- that is until the day he got fired for making one mistake. When the Dr would write a problem down, he would write the first two numbers and their operator down in a single numeric code... (one code per line). The answer he wrote down in a separate file.. That file has been lost. You have been hired to re-make it (given the professor's code). Since you are a little unsure of your work, you will put the problem and the answer in your file (so you can see you are right). The professor performed the conversions to his special coding system in his head -- so little is known about it. He will not tell you anything about it. His previous assistants had to figure it out for themselves. However, it is known that each number (that is, each parameter to the given math operator) in a math problem the professor looked at was less than 1000000000000. An anonymous witness says that the professor only did addition, subtraction and multiplication. It is also known that the first digit in his 'code' tells how many digits (1-9 inclusive) make up the first number "A" for problems of type A (operator) B = C.

After the first digit, are the specific coded digits composing the number "A". Then the next digit is the 'operator code'. For the operator code, it is known that '*' is coded as 0, '+' as 1, and '-' as 2 (no division). The operator code always follows the coded "A" digits. There will always be exactly one (1) operator code. "A" and "B" will always be positive. After the operator code, the remaining digits compose the coded digits for the number "B" (There will be always at least 1 digit for "B").

Your task is to decode the professor's file & find answers to his work! One last note: The professor had a strange habit of using different numerical digits in place of others... While we count 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (ascending numberical order); the professor counted 7, 8, 9, 0, 4, 5, 6, 1, 2, 3 (ascending numberical order). This means the professor didn't think about the numbers "A", "B", as we do. While we would think 1 + 2 = 3, the professor would think 7 + 8 = 9 for the same equation! For whatever reason, he only used digits 1,2,3 for operator codes. On rare occasion, out of delirium, he would write other digits for the operator codes, intending that they be 0,1, or 2. In those cases, he meant to write down the remainder of dividing those numbers by 3. (hence a 3 -> 0, 4 -> 1, 9 -> 0); The first digit in the professors 'code' is in our number system (1 = 1, 2 = 2, 9 = 9, etc). (The professor was weird, not cruel!)

Our system   :0 123 456 789
Prof's system:7 890 456 123

Input: You will read in the professor's code.. The first number will be a count of how many of the professor's codes follow. The first digit in the code specifies how many digits make up the number "A". The number "A" is made up of the specified number of [prof's numeric] digit(s) The next digit is the operator code. The remaining [prof's numeric code] digit(s) compose the number "B"

Output: You will output the professor's problem the way we would normally write math problems (e.g. 1 + 2 = 3) [using our numeric system]. You will have to convert the professors number system to that of ours (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) before you do any output.

Sample input:

4
1819
215199
15032
3555244

Sample Output:

 1  +   2 =    3 
75  +  22 =   97
 5  *  98 =  490
555 -  44 =  511



 

The statements and opinions included in these pages are those of 2001 LSU Computer Science High School Programming Contest only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 2000,2001 Isaac Traxler
Last modified: Friday, 01 July, 2011 16:24:51