One day, Nobita decided he wanted to go to the future to see who he would be getting married to. Unfortunately, his time machine broke and it sent him to a year that he did not want to go to!
Fortunately, Doraemon gave him a couple of gadgets in case something like this happened. He has an inflatable shelter (very high tech, even has an elevator), and a watch that always tells the correct time. Turns out, the time machine is a little awry but should be good to use by tomorrow. Once Nobita sets up his shelter and gets ready to sleep and wait for the time machine to fix itself, he checks his watch and notes that it's February 28th. He is suddenly curious now if tomorrow is February 29th or March 1st on the Gregorian Calendar.
Given the year that his watch displays, determine tomorrow's date! Remember that a leap year occurs when a year is divisible by 400, or it is divisible by 4 but not 100.
The first line of the input contains $$$n (1 \le n \le 100)$$$, the number of times Nobita traveled into the past. Then, the following $$$n$$$ lines each contain an integer $$$y (1 \le y \le 10000)$$$, a year that Nobita travels to.
For each of the $$$n$$$ years that Nobita traveled to, output either February 29 or March 1 depending on if the year is a leap year or not.
3 2000 1900 2004
February 29 March 1 February 29
Alfonso is a little bit of an Ancient Rome history buff and he is particularly fascinated by the Roman gladiator fights of the time. In the hopes of sharing his passion with others, Alfonso started 'Modern Gladiator', a company which built replicas of armor and weaponry used by the ancient Roman gladiators. Unfortunately for Alfonso, demand for his products has been fairly low in the modern era so Alfonso has come up with a brilliant new idea. Utilizing the newly invented time machine, Alfonso travels back in time with all his constructed armor and weaponry to the year 81 AD, the year the gladiator fights started being held in the newly constructed Colosseum.
Alfonso sets up his shop at the base of the Colosseum and word quickly spreads of the new mason in town with his fancy armor and weapons. Due to the superior metallurgy technology available to Alfonso in the present, his products were kilometers ahead in terms of strength to his counter-parts in the past. After a successful demonstration, prospective buyers queued up to buy one of Alfonso's products. Alfonso looks around and realizes that one bronze coin is probably a fair price for each of his products. However, he also realizes since he has just come to this era from the future, he doesn't have any Roman change to give to his customers at the start.
Each customer, when they reach the front of the line, buys exactly one product (which costs one bronze coin) and hands Alfonso either one bronze coin, one silver coin, or one gold coin. Now, two bronze coins are equivalent in value to one silver coin and two silver coins are equivalent to a single gold coin (so four bronze coins are equivalent to a single gold coin). Given that Alfonso doesn't have any change to start with, figure out if Alfonso can successfully attend to all the $$$n$$$ customers (by giving each of them the appropriate amount of change when it is their turn to buy something) in the line.
The first line will contain a single integer, $$$n$$$, representing the number of customers in the line (where $$$3 \leq n \leq 10^{5}$$$).
The following $$$n$$$ lines will each contain a string $$$c_i$$$ which will be one of three strings: 'gold', 'silver', and 'bronze' representing the coin that the $$$i$$$th customer pays with.
'YES' if it is possible for Alfonso to attend to (aka give the appropriate amount of change to) all his $$$n$$$ customers and 'NO' otherwise.
4 bronze bronze silver gold
YES
3 bronze silver gold
NO
In the first example, the first and second customers give the exact amount the product costs so Alfonso does not have to give any change back. Thus, he now has $$$2$$$ bronze coins. The next customer hands him a silver coin which means he needs to give a bronze coin back in change. He then has a bronze coin and a silver coin. The final customer hands him a gold coin which means that he needs to give $$$3$$$ bronze coins worth of change back so he can give the silver coin and bronze coin. Thus, he is able to give change for all $$$4$$$ of his customers.
After losing control of his time machine, Akash finds himself in the middle of late 19th century America, just as Thomas Edison is creating a festival to show off his light bulbs to the masses. Edison is planning on setting up the main showcase at a particular location, represented by a 2D point. To ensure his festival is a success, Edison wants every single person in town to see his festival by appropriately setting the brightness of the lights. If he makes the lights brighter, more people are able to see the lights, but it costs him more money to do so.
Given the locations of all the people in town as 2D points, Edison wants to find the farthest person from the main showcase so that he can set the brightness accordingly. Can Akash find the distance of the farthest person from Edison's showcase?
The first line will consist of a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) representing the number of people in town. The next line consists of two integers $$$a, b$$$ ($$$-10^9 \leq a, b \leq 10^9$$$) indicating the location of Edison's showcase. The next $$$n$$$ lines consist of two integers $$$x, y$$$ ($$$-10^9 \leq x, y \leq 10^9$$$) indicating that there is a person at coordinate $$$(x, y)$$$
Output the distance of the farthest person from Edison's main showcase. Your answer will be judged as correct if it is within $$$10^{-6}$$$ of the true answer.
2 0 0 1 0 -1 0
1.0
10 -95 32 -81 -93 61 -46 -21 79 -75 77 79 12 34 71 55 -55 -64 -36 68 -83 -2 33
199.48433522459854
In the year 1928, Otto Frederick Rohwedder invented the first single loaf bread-slicing machine, a technological advancement which would propel America forward decades, nay, centuries into the future–an invention on par with that of the wheel. Ever since Rohwedder's incredible breakthrough, historians have utilized the invention of sliced bread as a reference point for greatness against which all subsequent inventions can be compared. For instance, the invention of FM radio by Edwin H. Armstrong in 1933 rates at about a $$$0.65$$$ on the sliced bread scale, meaning that it was about $$$65\%$$$ as great as the invention of sliced bread.
Given a list of $$$N$$$ historical inventions, with the dates that they were invented and their ratings on the sliced bread scale, determine once and for all what objectively is the greatest thing since sliced bread?
The first line of input contains the integer $$$N$$$ ($$$1\leq N \leq 10^4$$$) which is the number of invention descriptions to follow. Then, each invention description consists of three lines. The first line gives the title of the invention. The second line gives the date that the invention was made, in the format 'MMM DD, YYYY' where the month is a three-letter abbreviation (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) and the day value (between 1 and 31) is one or two digits long. The third line of an invention description gives the invention's sliced bread score as a decimal value between 0 and 1 (clearly no invention could exceed the greatness of sliced bread).
Print out the title of the greatest invention since sliced bread, which is the one with the highest sliced bread score. Consider sliced bread to have been invented on Jul 7, 1928, such that any invention made after that date was invented 'since sliced bread.' Note that there will always be at least one invention made since sliced bread, and there will never be ties for greatest invention.
5 FM Radio Dec 26, 1933 0.65 Ballpoint Pen Oct 30, 1888 0.7442 Penicillin Sep 28, 1928 0.0036 The Hovercraft Dec 12, 1955 0.896 Fireworks Apr 20, 960 0.99999
The Hovercraft
Sylvia has been fascinated with Ancient Egypt and used her brand-new time machine to go back in time to the era of her favorite king, Ramses II. While King Ramses II was a highly successful leader, he was also highly eccentric and during her adventures, Sylvia found out that he had a very particular property that all hieroglyph sequences should follow in order for him to read it.
Each hieroglyph in the alphabet was assigned a unique number and King Ramses only accepted the message if the bit-wise XOR of all the numbers in the sequence was equal to $$$0$$$. Unfortunately, Sylvia did not know this before traveling back in time so she doesn't know if the message that she wrote for him satisfies his eccentric request. She also doesn't have too much time before her meeting with the King. Thus, she decides she will replace the minimum hieroglyphs possible in order to make the sequence fit his constraints. Given the numerical representation of the hieroglyphs that Sylvia has written, help her figure out the minimum number of elements in the sequence that need to be replaced in order to make the bitwise XOR of the sequence equal to $$$0$$$.
Note: The XOR between two bits is defined as a function that returns 1 if exactly one of the bits is a 1 and 0 otherwise. The bitwise XOR between two numbers is applying the XOR function on each of the corresponding bits (the last bit of the output is the XOR between the last bits of each of the input numbers and the second-to-last bit of output is the XOR of second-to-last bits of input and so on).
The first line of input will be a single integer $$$n$$$ (where $$$2 \leq n \leq 10^4$$$).
The second line of input will contain $$$n$$$ space-separated integers representing the elements in the sequence where $$$1 \leq h_i \leq 10^9$$$.
Output a single integer representing the minimum number of elements in the sequence that need to be replaced in order to make the bitwise XOR of the sequence equal to 0.
3 2 4 8
1
4 1 1 1 1
0
In the first sample test case, we can replace the first element with a 12 and then the bitwise XOR of the elements in the sequence is zero so the answer is 1. In the second test case, the bitwise XOR of the elements is already zero so the answer is 0.
Alice has traveled back in time to Ancient Greece to meet one of her greatest idols, the famous inventor Daedulus. When Alice visits, Daedulus is analyzing a few maze passageways that he is considering including in his latest creation, the soon-to-be famous Labyrinth. Alice jumps at the opportunity to help Daedulus and needs to build a solver that determines if a given maze passageway is solvable or not.
A maze passageway consists of $$$3$$$ rows that each have $$$n$$$ positions. Each position can either be blocked, which means that Alice cannot move through that position, or open, which means that Alice can move through that position. To solve a particular maze passageway, a person can move in any of the cardinal directions, as long as they don't move into a blocked position or go out of bounds of the passageway. Alice can start in any of the $$$3$$$ rows at the first position and can successfully solve the maze if she can reach the final position at any of the $$$3$$$ rows.
Given a particular maze passageway that meets these criteria, you must output Solvable! if Alice can solve the maze passageway and Unsolvable! otherwise.
The first line will consist of a single integer $$$n$$$ ($$$2 \leq n \leq 10^4$$$), which gives the number of positions per row. The next $$$3$$$ lines consist of a string, $$$s$$$, with $$$n$$$ characters that are either 0 or 1, representing a row of the maze passage way. If $$$s_i = $$$ 0, then the $$$i$$$th position in that row is open, and if $$$s_i = $$$ 1, then the $$$i$$$th position in that row is blocked.
Output Solvable! if the maze passageway is solvable and Unsolvable! otherwise.
2 00 10 00
Solvable!
2 01 10 10
Unsolvable!
Gloria is a ravenous reader and has recently been enraptured by Shakespeare's 'Othello'. Lucky for her, this new time travel device provided her the perfect opportunity to go back in time to November 1, 1604, and watch her favorite play in person. Gloria dresses up in her finest Shakespearean-era attire and zooms back in time. To prevent the time travel machine from ending up in the wrong hands, each user is given a specific numeric password and a set of recovery codes in case they forget the password.
Gloria reaches the Whitehall Palace just in time for the show and after an enthralling three and a half hours, she returned to her time travel machine only to realize that she has forgotten her password! Luckily, she had the foresight to bring her tablet with the recovery codes on her. However, the effect of time travel on such electronics was unfortunately still not completely mitigated so some of the bits in the tablet got shifted around. Fortunately, Gloria knows that each of the recovery code numbers was rearranged in the exact same way and that her password is the smallest possible difference between the maximum recovery code and the minimum recovery code. Help Gloria recover her password!
That is, given the list of $$$n$$$ rearranged recovery codes, each of which is exactly $$$k$$$ digits, permute all of the numbers in the exact same way in order to get the minimum possible difference between the maximum and minimum recovery code after the permutation.
The first line of the input will contain two space-separated integers, $$$n$$$ and $$$k$$$ (where $$$2 \leq n \leq 100$$$ and $$$1 \leq k \leq 9$$$).
$$$n$$$ lines of input will then follow, each line containing a single integer $$$x_i$$$ ($$$0 \leq x_i \leq 10^{k} - 1$$$) which will have exactly $$$k$$$ digits (the number can contain leading zeros).
A single integer representing Gloria's password aka the minimum difference between the maximum and minimum recovery code after the permutation.
2 2 12 32
2
4 4 1842 0141 5581 1581
1017