# Codyssi - Absurd Arithmetic! ## Part 1 Difficulty Rating: 1 You and your team are now on course to the seaside. It’s getting pretty late though, so why not rest? After all, you’ll probably need it. You arrive at the nearest hotel. You walk in, and registration goes quite well! Well, up until the peculiar payment process. The hotel accepts normal currency, but they calculate their prices in exponentialis pecunia. Oddly, its exchange rate to standard currencies increases exponentially. Why would anyone ever use this? “Don’t worry, we have a machine that converts from exponentialis pecunia to standard currency. I just need the book of room pricings… Here it is… Wait, it’s not here? Oh no…” The clerk has lost her pricing book—you’ll have to help her calculate the room prices! “There are 3 pricing functions used to calculate room prices. To calculate the price of a room, you start with the quality of the room. First, apply function C, then apply function B, and then apply function A. The resulting value is the one-night price of a room in exponentialis pecunia.” To figure out if you’ll have enough money to stay for the night, a good point to start would be to consider the median-quality room. You remind yourself that the median is the middle value in a sorted list. For example, consider the following list with 11 room qualities and 3 different pricing functions: Function A: ADD 495 Function B: MULTIPLY 55 Function C: RAISE TO THE POWER OF 3 5219 8933 3271 7128 9596 9407 7005 1607 4084 4525 5496 For these room qualities, the median quality is 5496. Applying function C, you get 166012263936. Applying function B to that result gives you 9130674516480. Finally, applying function A to that result gives 9130674516975. So the one-night price of the median-quality room, in exponentialis pecunia, is 9130674516975. Consider the list of 101 room qualities and the 3 pricing functions given to you. What is the one-night price of the median-quality room in exponentialis pecunia? (Enter your answer as a single number without commas.) ## Part 2 Difficulty Rating: 2 When converted to normal currency, that actually seems quite cheap! Though, each member of your team will probably need their own rooms, won’t they… “Oh, about that, the hotel charges extra fees for booking more than one room. To calculate the total one-night price for many rooms, you first sum all the rooms’ qualities. Then, you apply function C, then B, then A on the sum. This will give you the one-night price of the rooms in exponentialis pecunia.” To get a (very, very generous) upper bound estimate of the total price for your team, you decide to calculate the total price of booking all the rooms with even-numbered room qualities for one night. For example, consider the same list with 11 room qualities and 3 different pricing functions: Function A: ADD 495 Function B: MULTIPLY 55 Function C: RAISE TO THE POWER OF 3 5219 8933 3271 7128 9596 9407 7005 1607 4084 4525 5496 The even-numbered room qualities are 7128, 9596, 4084, and 5496. Their sum is 26304, so by applying the 3 pricing functions in the correct order, the total one-night price of booking these rooms is 1000986169836015. Considering your file, what is the total one-night price of all the rooms with an even-numbered room quality, in exponentialis pecunia? ## Part 3 Difficulty Rating: 2 The upper bound still seems quite reasonable! You and your team members choose rooms and pay for your stay—off to a good night’s sleep! As the rest of your team members head to their rooms, you notice the clerk bring out an abnormally large pile of paper. She begins to write furiously, and she seems quite stressed. You’ve gotten too curious now… “I have to calculate some room prices since, you know, I lost the pricing book. Come to think of it, you calculated your room prices quite quickly… Do you mind helping me out?” She won’t get any sleep without your help, so you can’t really say no, can you? She explains the situation to you. A client wants to book a room for one night. He can pay at most 15000000000000 exponentialis pecunia, and he wants the highest quality room that he can afford. You’ll have to determine the quality of the room that fits the client’s request. For example, consider the same list with 11 room qualities and 3 different pricing functions: Function A: ADD 495 Function B: MULTIPLY 55 Function C: RAISE TO THE POWER OF 3 5219 8933 3271 7128 9596 9407 7005 1607 4084 4525 5496 For this sample file, the highest quality room that the client could afford is 5496. So, the answer for this sample file is 5496. Consider the list of the room qualities and the pricing functions given to you. What is the highest-quality room that the client can afford?