12
Luka is fooling around in chemistry class again! Instead of balancing equations he is writing coded sentences on a piece of paper. Luka modifies every word in a sentence by adding, after each vowel (letters ’a’, ’e’, ’i’, ’o’ and ’u’), the letter ’p’ and then that same vowel again. For example, the word “kemija” becomes “kepemipijapa” and the word “paprika” becomes “papapripikapa”. The teacher took Luka’s paper with the coded sentences and wants to decode them. Write a program that decodes Luka’s sentence. Input The coded sentence will be given on a single line. The sentence consists only of lowercase letters of the English alphabet and spaces. The words will be separated by exactly one space and there will be no leading or trailing spaces. The total number of character will be at most 100. Output Output the decoded sentence on a single line. Sample Input 1 zepelepenapa papapripikapa Sample Output 1 zelena paprika Sample Input 2 bapas jepe doposapadnapa opovapa kepemipijapa Sample Output 2 bas je dosadna ova kemija Source: Croatian Open Competition in Informatics 2008/2009, contest #3. License: For educational use only Kemija

Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

Luka is fooling around in chemistry class again! Instead of balancing equations he is writing coded sentences on a piece ofpaper. Luka modifies every word in a sentence by adding, after each vowel (letters ’a’, ’e’, ’i’, ’o’ and ’u’), the letter ’p’ and thenthat same vowel again. For example, the word “kemija” becomes “kepemipijapa” and the word “paprika” becomes“papapripikapa”. The teacher took Luka’s paper with the coded sentences and wants to decode them.

Write a program that decodes Luka’s sentence.

Input

The coded sentence will be given on a single line. The sentence consists only of lowercase letters of the English alphabet andspaces. The words will be separated by exactly one space and there will be no leading or trailing spaces. The total number ofcharacter will be at most 100.

Output

Output the decoded sentence on a single line.

Sample Input 1

zepelepenapa papapripikapa

Sample Output 1

zelena paprika

Sample Input 2

bapas jepe doposapadnapa opovapa kepemipijapa

Sample Output 2

bas je dosadna ova kemija

Source: Croatian Open Competition in Informatics 2008/2009, contest #3. License: For educational use only

Kemija

Page 2: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For examplethey own a die that has 10 sides with numbers 47,48,…,56 on it.

There has been a big storm in Stockholm, so Gunnar and Emma have been stuck at home without electricity for a couple ofhours. They have finished playing all the games they have, so they came up with a new one. Each player has 2 dice which heor she rolls. The player with a bigger sum wins. If both sums are the same, the game ends in a tie.

Task

Given the description of Gunnar’s and Emma’s dice, which player has higher chances of winning?All of their dice have the following property: each die contains numbers , where and are the lowest andhighest numbers respectively on the die. Each number appears exactly on one side, so the die has sides.

Input

The first line contains four integers that describe Gunnar’s dice. Die number contains numbers on its sides. You may assume that . You can further assume that each die has at least

four sides, so .

The second line contains the description of Emma’s dice in the same format.

Output

Output the name of the player that has higher probability of winning. Output “Tie” if both players have same probability ofwinning.

Sample Input 1

1 4 1 4 1 6 1 6

Sample Output 1

Emma

Sample Input 2

1 8 1 8 1 10 2 5

Sample Output 2

Tie

Dice game

a, a + 1, … , b a bb − a + 1

, , ,a1 b1 a2 b2 i, , … ,ai ai+1 bi 1 ≤ ≤ ≤ 100ai bi

≤ai+3 bi

Page 3: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

Sample Input 3

2 5 2 7 1 5 2 5

Sample Output 3

Gunnar

Author: Lukáš Poláček. Source: Nordic Collegiate Programming Contest 2014. License: Creative CommonsLicense (cc by-sa)

Page 4: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

You are attempting to climb up the roof to fix some leaks, and have to go buy a ladder. The ladder needs to reach to the top ofthe wall, which is centimeters high, and in order to be steady enough for you to climb it, the ladder can be at an angle of atmost degrees from the ground. How long does the ladder have to be?

Input

The input consists of a single line containing two integers and , with meanings as described above. You may assume that and that .

Output

Write a single line containing the minimum possible length of the ladder in centimeters, rounded up to the nearest integer.

Sample Input 1

500 70

Sample Output 1

533

Sample Input 2

1000 10

Sample Output 2

5759

Author: Per Austrin. Source: Spotify Challenge 2010. License: Creative Commons License (cc by-sa)

Ladder

hv

h v1 ≤ h ≤ 10000 1 ≤ v ≤ 89

Page 5: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

Yi has moved to Sweden and now goes to school here. The first years of schooling she got in China, and the curricula do notmatch completely in the two countries. Yi likes mathematics, but now… The teacher explains the algorithm for subtraction onthe board, and Yi is bored. Maybe it is possible to perform the same calculations on the numbers corresponding to thereversed binary representations of the numbers on the board? Yi dreams away and starts constructing a program thatreverses the binary representation, in her mind. As soon as the lecture ends, she will go home and write it on her computer.

Task

Your task will be to write a program for reversing numbers in binary. For instance, the binary representation of 13 is 1101, andreversing it gives 1011, which corresponds to number 11.

Input

The input contains a single line with an integer , .

Output

Output one line with one integer, the number we get by reversing the binary representation of .

Sample Input 1

13

Sample Output 1

11

Sample Input 2

47

Sample Output 2

61

Author: Emma Enström. Source: KTH Challenge 2011. License: Creative Commons License (cc by-sa)

Reversed binary numbers

N 1 ≤ N ≤ 1000000000

N

Page 6: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

On the planet Htrae Friday the 13th is a lucky day. You are going there on the next space ship and want to calculate howmany times it happens during a given year. Unfortunately they change their calendar every year. Every year starts on aSunday, but other than that, they change everything. They have released a list of calendar specifications for the next fewyears. A calendar specification consists of the total number of days in the year, the number of months in the year, and thenumber of days in each of the months.Your task is to figure out how many times there will be Friday the 13th based on the calendar specifications.

Input

The first line of the input consists of a single integer, , the number of test cases.The first line of each of the test cases is a line with two space separated integers, and , the total number of days in theyear and the number of months in the year respectively. The second line of each test case consists of space separatedintegers, , the number of days in each month.

Output

For each test case, output the number of Friday the 13ths in the specified year.

Sample Input 1

3 20 1 20 40 2 21 19 365 12 31 28 31 30 31 30 31 31 30 31 30 31

Sample Output 1

1 22

Author: Torbjørn Morland. Source: IDI-Open 2015. License: Creative Commons License (cc by-sa)

Friday 13th

TT D M

Mdi

1 ≤ T ≤ 201 ≤ M ≤ D ≤ 10001 ≤ di ≤ 100

= D∑i di

Page 7: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

One day, little Mirko came across a funny looking machine! It consisted of a very very large screen and a single button. Whenhe found the machine, the screen displayed only the letter A. After he pressed the button, the letter changed to B. The nextfew times he pressed the button, the word transformed from B to BA, then to BAB, then to BABBA… When he saw this, Mirkorealized that the machine alters the word in a way that all the letters B get transformed to BA and all the letters A gettransformed to B.

Amused by the machine, Mirko asked you a very difficult question! After K times of pressing the button, how many letters Aand how much letters B will be displayed on the screen?

Input

The first line of input contains the integer ( ), the number of times Mirko pressed the button.

Output

The first and only line of output must contain two space-separated integers, the number of letters A and the number of letterB.

Sample Input 1

1

Sample Output 1

0 1

Sample Input 2

4

Sample Output 2

2 3

Sample Input 3

10

Sample Output 3

34 55

Riječi

K 1 ≤ K ≤ 45

Page 8: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

Author: Marin Tomić. Source: Croatian Open Competition in Informatics 2013/2014, contest #3. License: Foreducational use only

Page 9: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

Fatima Cynara is an analyst at Amalgamated Artichokes (AA). As with any company, AA has had some very good times aswell as some bad ones. Fatima does trending analysis of the stock prices for AA, and she wants to determine the largestdecline in stock prices over various time spans. For example, if over a span of time the stock prices were 19, 12, 13, 11, 20and 14, then the largest decline would be 8 between the first and fourth price. If the last price had been 10 instead of 14, thenthe largest decline would have been 10 between the last two prices.Fatima has done some previous analyses and has found that the stock price over any period of time can be modelledreasonably accurately with the following equation:

where and are constants. Fatima would like you to write a program to determine the largest price decline over agiven sequence of prices. Figure 1 illustrates the price function for Sample Input 1. You have to consider the prices only forinteger values of k.

Figure 1: Sample Input 1. The largest decline occurs from the fourth to the seventh price.

Input

The input consists of a single line containing 6 integers ( ), , , , ( ) and (). The first 5 integers are described above. The sequence of stock prices to consider is

.

Output

Display the maximum decline in the stock prices. If there is no decline, display the number 0. Display your output in twodecimal places.

Sample Input 1

42 1 23 4 8 10

Artichokes

price(k) = p ⋅ (sin(a ⋅ k + b) + cos(c ⋅ k + d) + 2)

p, a, b, c d

p 1 ≤ p ≤ 1000 a b c d 0 ≤ a, b, c, d ≤ 1000 n1 ≤ n ≤ 106

price(1), price(2), … , price(n)

Page 10: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

Sample Output 1

104.85

Sample Input 2

100 7 615 998 801 3

Sample Output 2

0.00

Sample Input 3

100 432 406 867 60 1000

Sample Output 3

399.30

Source: ACM-ICPC World Finals 2015. License: Restricted, used with permission

Bad domain: https://kth.kattis.com/problems/arti…

Bad domain: https://open.kattis.com/problems/d…

Bad domain: https://open.kattis.com/problems/fr…

Bad domain: https://open.kattis.com/problems/k…

Bad domain: https://open.kattis.com/problems/l…

Bad domain: https://open.kattis.com/problems/n…

Bad domain: https://open.kattis.com/problems/r…

Bad domain: https://open.kattis.com/problems/ri…

Auto-validate on refresh

Close Show Valid

Page 11: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

Lovisa is at KTH listening to Stefan Nilsson lecturing about perfect binary trees. “A perfect binary tree has a distinguishednode called the root which is usually drawn at the top. Each node has two children except the nodes in the lowest layer, whichwe call leaves.” Lovisa knows all this already, so she is a bit bored. Noticing this, Stefan comes up with a new challenge forLovisa.

First, we label the nodes of a perfect binary tree with numbers as follows. We start at the bottom right leaf which gets number1 and then label nodes on the same level in increasing order from right to left. After finishing a level, we move to the rightmostnode in the level above and label all the nodes on that level from right to left. We proceed in this fashion until we reach theroot.

When we want to describe a node in the tree, we can do it by describing a path starting at the root and going down toward theleaves. At each non-leaf node we can either go left (‘L’) or right (‘R’).

Figure 1: Labeled binary tree of height 3 with two marked paths from the root. Path LR leads to label 11 while path RRL leadsto 2. The root has number 15.

Task

Lovisa’s task is to calculate the label of a node, given the height of the tree H and the description of the path from the root.

Input

The only line of input contains the height of the tree , and a string consisting of the letters ‘L’ and ‘R’, denotinga path in the tree starting in the root. The letter ‘L’ denotes choosing the left child, and the letter ‘R’ choosing the right child.The description of the path may be empty and is at most letters.

Output

Output one line containing the label of the node given by the path.

Sample Input 1

Numbers on a Tree

H 1 ≤ H ≤ 30

H

Page 12: Kemija - Universiteit Utrechtleeuw041/problems.pdf · Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6-sided dice. For example they own

3 LR

Sample Output 1

11

Sample Input 2

3 RRL

Sample Output 2

2

Sample Input 3

2

Sample Output 3

7

Author: Lukáš Poláček. Source: KTH Challenge 2014. License: Creative Commons License (cc by-sa)