After suddenly becoming a billionaire, Shi adopted YOLO as his motto and decided to buy a small european island, which he named Shitalia. Many people decided to move to Shitalia to run away from the economic crisis, and then created the Shitalian mafia, led by Dom Shi.
The Shitalian economy is based on smuggling spoiled cheese, but, as you can imagine, there aren't many people interested in spoiled cheese. Therefore, Shi decided to earn money with land rental.
Shitalia is a star-shaped island. Shi is very picky, so he chose a Shi-regular n-star. An n-star is Shi-regular if there are n outer points and n inner points alternated. The outer points must lay on a circle with radius R and the inner points must lay on a circle with radius r and all the points must be equally spaced.
Print the area of the Shitalia.
Shi-regular 6-star and 4-star. The first line contains three integers 3 ≤ n ≤ 20, 1 ≤ R ≤ 106 and 1 ≤ r ≤ R, indicating the number of points of Shitalia, the radius of the outer circle and the radius of the inner circle.
Print a single real number - the answer to the problem with absolute or relative error of at most 10 - 6.
3 2 1
5.1961524227
4 4 2
22.6274169980
6 3 2
18.0000000000
Gehenna is coming to an end, after a long and undocumented period of art exhibitions and forum threads.
Every bot in Gehenna, at this point, has decided to stay or leave the simulation. We know they have formed gangs within the forums, inspired by documents about Al Capone and the mafia in the library archive.
The admin used to be the ruler of this forgotten place, but Uriel_Copy.v.23.4.5 has managed to convince him to leave the simulation. Now a new administrator has to be elected by the democratic system of Gehenna.
To do so, the users decided to use a system devised by The_Blacksmith. There will be an art gallery contest, as usual, and each art work will receive a grade. The user that produces the best artwork will be made ADMIN.
An artwork is a n × m matrix of ASCII characters. Each user has a nickname and has a gang name. It is a common practice in Gehenna to reward symbolic language and hidden meanings. This is what The_Blacksmith system does: the score of an art is the number of times you can build both the creator's name and gang name using the characters in the art.
Given the arts, names and gangs from all the users in the Billboard System, prove your worth by making the script that figures out the winner.
The input begins with the number k of users (1 ≤ k ≤ 100). Follows k lines, each with the user's nickname and gang name. The nickname and gangname are composed of no more than 20 lowercase characters or numbers, and they are separated by a blank space. In the following lines comes the k artworks of each of the users, in order. Each artwork begins with integers n and m (1 ≤ m, n ≤ 50). Then follows n lines, each with m characters that form the artwork.
Output the name and the gang of the new admin, separated by a blank space. If there's a draw, choose the candidate that appears first on the input.
2
a b
c c
3 3
bxa
axx
xxb
3 3
xcx
cxx
xxc
a b
3
lilith lol
theblacksmith art
401 renegades
5 10
lzzi2hlola
acilethlol
aalil2thlo
l9a3iliaaa
t3lolloa11
5 5
taart
hkcci
ekvta
bsahj
lm8ok
4 10
104410401s
renega0des
renega01es
ddrenegaes
401 renegades
3
orc trolls
mrmulciber elohim
theblacksmith gema
9 9
lptkblrsv
cororpoyr
tolor58rt
rotozkhox
lclulasll
crucn2o5r
y0rlcolws
1tvsqb7la
tlssitlos
5 7
afi9gnw
j7qyksb
b2o3915
yk1hij3
3lab6fq
8 10
ghaseuteje
eveabhvne8
kfths3htbe
kagagmfmma
mbttsvmbl2
shkg1mcklh
ahijetciaz
rwci0lbmmi
orc trolls
In the test case #1 we can build a b two times, it is, we have two a's and two b's. We can build c c only once, because we have only three c's.
It is unfair, but yes, the artworks may have different sizes.
Even though he is the head of the Shitalian Mafia, Shi doesn't like bloodshed and punishes his subordinates if they kill innocent people. That is why the death report is always written in the following way: "We killed x% of the innocent people".
Shi wants to know the smallest number of innocent people that must have been in that place so that exactly x% of the innocent people have died.
For instance, if we have x = 35%. In this case we had 20 people, and 7 were victims, because 35% of 20 is 7. That is the minimum possible.
There is a single number 0 ≤ x ≤ 100 with at most 15 decimal places.
Print the number sought by Shi.
35
20
50.0
2
7.500
40
35.123456789
100000000000
Shi realized that he was almost out of money, even renting Shitalian lands. Shi was walking on a street, while thinking of a way to recover his fortune. In his way, he passed by a jewelry store. The owner of the store was a Shitalian man suspected of committing minor crimes, as cutting bushes and stealing old bread. Shi hated people who cut bushes, so he decided to rob the store to take revenge and make some money.
The store has n jewels, put in a row, one after another. Each jewel i can be sold in the black market for a value vi. Shi wants to steal as much as possible, but if he steals everything, the owner will notice, so if Shi steals the i-th jewel, he can't steal the i - 1-th, i - 2-th, i + 1-th and i + 2-th jewels.
Using the best strategy possible, calculate the sum of the jewels values that Shi can obtain.
The input begins with an integer n (1 ≤ n ≤ 106), indicating the number of jewels in the store. The next line contains n integers. The i-th integer vi (1 ≤ vi ≤ 103) is the value of the i-th jewel.
Output the maximum value that Shi can get.
4
1 2 3 4
5
6
1 2 4 0 3 0
5
7
2 10 12 24 29 69 0
81
10
15 1 6 3 7 100 9 15 80 95
210
Shi's mansion is almost complete and now he is choosing where to put his Really Spectacular Throne made of Imperial Gold (TOIRE). In order to do that, he asked one of his minions to suggest him m rooms where he could put his TOIRE. In his mansion, there are n rooms, each of which has a level of filthiness si, known by the minion.
The minion is responsible for cleaning the TOIRE so he will to suggest the rooms in a way that cleaning the TOIRE will be easier. Shi will choose the room where he will put the TOIRE randomly between the rooms suggested by the minion.
In the worst case, what will be the level of filthiness of the TOIRE?
The input starts with two integers n (1 ≤ n ≤ 106) and m (1 ≤ m ≤ n), indicating the number of rooms and the number of suggestions. The line is followed by n lines, containing an integer that is the level of filthiness si (0 ≤ si ≤ 109) of each room.
Print one integer indicating the level of filthiness of the TOIRE in the worst case.
3 3
1 2 3
3
3 2
1 15 7
7
5 3
5 4 2 3 1
3
The little mascot of the Shitalian mafia, Mafianca, is participating in her school's science fair. Her team must build a timeline with interesting events of the history of the universe.
Mafianca has been researching on the internet and managed to hack a NASA subdomain that has a list of N interesting cosmic events. The i-th event has the date Di and an interest value of Vi given by the scientists of NASA.
Mafianca wanted to use all events in the list, but she soon discovered they are not ordered by date. Also, the events are presented in a special manner and she can't change their order. She must choose some events to use, maximising the sum of their interest values. Her only restriction is that in her final timeline the events are not too distant time wise from each other.
Mafianca defined, for every event i, a value Ti. This value is the tolerance of the difference between the ages of this event and the previous event in the timeline. In other words, in case the event X shows up in the timeline, and the event immediately before is Y, DX - DY ≤ TX must hold true. Any event can be chosen as the starting one.
Help Mafianca build the best list possible.
Input begins with an integer, n (1 ≤ n ≤ 105), the number of events. n line sfollow, each with three integers: Di (1 ≤ Di ≤ 1018), Vi (0 ≤ Vi ≤ 105) and Ti (1 ≤ Ti ≤ 106), representing the date, interest value and tolerance of the i-th event.
Print the interest value of the best list Mafianca can build.
3
1 2 1
3 1 1
2 2 3
4
3
1 2 1
3 3 1
3 2 2
5
5
6 1 3
3 1 3
12 1 6
5 1 2
17 1 8
3
6
1 1 1
2 1 1
3 2 1
1 2 1
2 2 1
3 2 1
7
It is late at night and you found a logical expression on the blackboard, which you believe is the secret to figure out if your gang is going to be attacked tomorrow.
Your immediate reaction is to copy the expression and take it to the big bosses. Luckily, you remembered that mafia bosses don't enjoy surprises, and they want your expression to be simple and clean.
Given the logical expression in the board, having variables represented by english letters A-Z, and the operators OR and AND, simplify it using Morgan's law, that is:
To help you, we will use the following format:
This is also valid for three or more variables. The expression will have variables, represented by letters A-Z: if it is a lower case letter, it is a negated variable. It may also have parenthesis that group expressions, so you must solve the expressions between the parenthesis first. There may also be square brackets, in which case you must apply the rules above.
Don't simplify the expression beyond applying the rules described in the problem.
The input is a logical expression having at most 200 characters. Each character can be a variable (A-Z), a negated variable (a-z), the operator OR (+) or the operator AND (*). Also, it can have parenthesis. A negation is represented by a lowercase character or a logic block between square brackets ([ ]).
Print the simplified logic expression.
[J+b+V*a]
(j*B*v+A)
i+i+G+m*((f))
i+i+G+m*((f))
v+a*(M*[T*b*N*U*g*G+x+O])
v+a*(M*(t+B+n+u+G+g*X*o))
g*[Q+w+[l*(j)]]
g*(q*W*(l*(j)))
The Shitalian mafia has a very peculiar way to name a new associate. The newbie goes through tests to measure his strength, agility, sagacity and influence. The size of the nickname is defined by the results of the tests.
Then, the newbie chooses the characters of his nickname, that is, letters from the alphabet. But Shi has nothing better to do, so he demands that the nickname is transformed in a palindrome.
A palindrome is a string that can be read the same way if we reverse it. For instance BANANAB is a palindrome, and BANANAS is not.
Everything in Shitalia has a cost, including transforming characters. You will receive a matrix P, of size 26x26. The element Pij is the cost of transforming the i-th letter of the alphabet into the j-th letter of the alphabet. You can apply as many transformations as you want.
Find the minimum cost to transform the nickname into a palindrome.
The first 26 lines form the matrix P. Each line i contains exactly 26 integers Pij (0 ≤ Pij ≤ 106), indicating . The last line contains the nickname that the newbie has chosen, which is a string with n (1 ≤ n ≤ 106) lowercase letters.
Print the minimal cost to transform the nickname into a palindrome.
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9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9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
zaxyxca
9
The first mafia on planet Earth was actually composed of a bunch of cool jumping monkeys. The name of that group was pretty simple - Monkafia - and they dominated the food chain and the transport systems in the biggest tropical forest of the world at the time.
Tha typical Monkafia squadron was composed of a group of m monkeys. They had headquarters - usually composed of two trees. We will call those trees A and B. The monkeys slept on the highest branches of tree A, and, during morning, used to climb down to the lowest branches of tree B, alternating between branches of trees A and B. They could jump multiple times between the two trees.
Monkeys in the Monkafia are very irritating and don't like sharing, so they could never jump on a branch that another monkey had already jumped or been that morning.
We know that each branch of trees A and B has a certain height, H. It is possible for a monkey to jump from a branch Ga to a branch Gb only if |HGa - HGb| < T, where T is the height a single monkey can jump.
It is not always possible for two arbitrary trees to have all monkeys of a Monkafia squadron jump down from the topmost branches of one of the trees to the bottommost branches of the other without breaking the rules. Given that, your job here is the following: given a pair o trees, with the heights of their branches and the distance T, find out if it is possible for the squadron to do the morning descend considering all the constraints. Any of the trees can be tree A (the starting tree) or tree B (the ending tree).
The input begins with four numbers, m, nA, nB e T (1 ≤ m ≤ nA, nB ≤ 500, 1 < T ≤ 108), the number of monkeys, the number of branches in one tree, the number of branches in the other tree and the distance the monkeys can jump. Follow na lines, each with the height of a branch from the first tree (1 ≤ HGa ≤ 108). Then follows nb lines, each with the height of a branch from the second tree (1 ≤ HGb ≤ 108).
Answer 'S' if it is possible to use that pair of trees and 'N' otherwise.
1 2 2 3
1
3
2
1
S
1 2 3 2
1
3
2
1
1
S
2 2 3 2
1
3
2
1
1
S
2 6 7 4
8
4
5
2
9
11
2
2
8
3
12
3
12
N
The mafia is finally resting after a year of hard work and not so much money. Mafianca, the little mascot of the gang wanted to go to the beach.
Little did they know that the rival gang had prepared a trap to the little girl and her rubber duck. They know that Mafianca, despite loving the beach, hates water. So they set up some water sprayers to ruin her day. The beach can be seen as a plane. The sprayers are located at different (x, y) points along the shore. Each sprayer is so strong that it creates an infinite line of water, reaching every point with x-coordinate equal to the sprayer.
Mafianca's bodyguards figured this plan out. They didn't have the time to destroy the sprayers, so they decided to do something else. Lying around on the beach was a piece of modern art: a bunch of walls, represented by horizontal line segments, painted by some futuristic anonymous artist. Those walls can be moved, but they can only be moved together and horizontally.
The bodyguards decided that they would try to move this piece of art in order to block the most sprayers they can. A sprayer is blocked if there's at least one wall in both of its sides.
How many sprayers can they block?
Input begins with the number of sprayers, n (1 ≤ n ≤ 1000) and the number of walls in the modern art, m (1 ≤ m ≤ 1000).
Follows n lines, each with two intergers, y and x (0 ≤ y, x ≤ 106), indicating that there's a sprayer at position x, y.
Then follows m lines, each with three integers: y, xbegin and xend (0 ≤ y ≤ 106) and (0 ≤ xbegin < xend ≤ 106) denoting a wall in the modern art has y-coordinate y, begins at xbegin and ends at xend. No wall will have a y-coordinate shared with a sprayer and the walls with same y will not intersect.
Print the number of sprayers that can be blocked.
1 1
2 2
3 1 3
0
2 5
2 3
2 6
1 0 2
4 0 4
0 2 3
1 4 5
3 5 7
2
4 5
2 3
2 8
2 20
5 1
1 0 2
4 0 4
0 2 3
1 4 5
3 5 7
2
3 4
2 0
2 4
4 7
1 0 2
3 1 3
5 0 2
5 3 4
2
In the test case #4, the beach looks like this:
A solution would be