COCI 2008/2009 Contest #5, 7 th February 2009 TASK LJESNJAK JABUKA JAGODA LUBENICA TRESNJA KRUSKA

Similar documents
TASK FUNGHI ZMIJA TRAKTOR ZGODAN JABUKE DIVLJAK. standard input (stdio) standard output (stdout)

TASK OKUPLJANJE USPON RAZINE ABECEDA STEP VODA. uspon.pas uspon.c uspon.cpp. razine.pas razine.c razine.cpp

COCI 2008/2009 Contest #3, 13 th December 2008 TASK PET KEMIJA CROSS MATRICA BST NAJKRACI

COCI 2008/2009 Contest #6, 7 th March 2009 TASK BUKA BAZEN NERED CUSKIJA DOSTAVA SLICICE

CROATIAN OPEN COMPETITION IN INFORMATICS. 7 th ROUND

TASK BELA PUTOVANJE PIANINO PAROVI KRUMPIRKO SAN. standard input (stdin) standard output (stdout)

COCI 2008/2009 Contest #1, 18 th October 2008 TASK SKOCIMIS PTICE MRAVOJED JEZ SKAKAVAC KRTICA

TASK NOP CIJEVI ROBOTI RELJEF. standard output

Q i e v e 1 N,Q 5000

TASK JACK PROZORI ZAGRADE REZ PASTELE KOŠARE. zagrade.pas zagrade.c zagrade.cpp. time limit 1 second 1 second 1 second 1 second 5 seconds 2 second

MAT3707. Tutorial letter 202/1/2017 DISCRETE MATHEMATICS: COMBINATORICS. Semester 1. Department of Mathematical Sciences MAT3707/202/1/2017

COCI 2017/2018. Round #1, October 14th, Tasks. Task Time limit Memory limit Score. Cezar 1 s 64 MB 50. Tetris 1 s 64 MB 80

Targets - Year 3. By the end of this year most children should be able to

Croatian Open Competition in Informatics, contest 5 February 23, 2008

Words Mobile Ready Game Documentation

COCI 2008/2009 Contest #4, 17 th January 2009 TASK MJEHURIC DATUM ROT SLIKAR TREZOR PERIODNI

TASK ŠEĆER KOLO GITARA POŠTAR KUGLICE UPIT. kolo.pas kolo.c kolo.cpp. gitara.pas gitara.c gitara.cpp

The 2016 ACM-ICPC Asia China-Final Contest Problems

ACM International Collegiate Programming Contest 2010

Problem F. Chessboard Coloring

2006 Canadian Computing Competition: Junior Division. Sponsor:

2016 Canadian Computing Olympiad Day 2, Problem 1 O Canada

# 1. As shown, the figure has been divided into three identical parts: red, blue, and green. The figures are identical because the blue and red

Problem Set 7: Games Spring 2018

TASK GLASNICI KOLEKCIJA TAMNICA UMNOZAK

Taiwan International Mathematics Competition 2012 (TAIMC 2012)

1. Anthony and Bret have equal amounts of money. Each of them has at least 5 dollars. How much should Anthony give to Bret so that Bret has 10

Whenever possible, ask your child to tell you the time to the nearest 5 minutes. Use a clock with hands as well as a digital watch or clock.

Southeastern European Regional Programming Contest Bucharest, Romania Vinnytsya, Ukraine October 21, Problem A Concerts

CROATIAN OPEN COMPETITION IN INFORMATICS. 4th round

Problems translated from Croatian by: Paula Gombar

Kangaroo 2017 Benjamin (6th and 7th grade)

The 2013 British Informatics Olympiad

saying the 5 times, 10 times or 2 times table Time your child doing various tasks, e.g.

Let s Make. Math Fun. Volume 19 January/February Dice Challenges. Telling the Time. Printable Games. Mastering Multiplication.

Arbiter Sports Officials Quick Start Guide

FRI Summer School Final Contest. A. Flipping Game

Assignment 1, due Monday September 19, 2005

Standard Sudoku point. 1 point. P a g e 1

Do not duplicate or distribute without written permission from CMKC!

Y8 & Y9 Number Starters A Spire Maths Activity

National Curriculum Statement: Substitute values into formulas to determine an unknown (ACMNA234)

Grade 6 Math Circles February 21/22, Patterns - Solutions

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25. Homework #1. ( Due: Oct 10 ) Figure 1: The laser game.

Four mice have found a lump of cheese. Draw where they should cut it so that they each have an equal amount. Each mouse has of the c

Chapter 4 Number Theory

CISC 1400 Discrete Structures

Spring 06 Assignment 2: Constraint Satisfaction Problems

Episode 4 30 th March 2 nd April 2018 Odd Even & Substitution Variations By R Kumaresan and Amit Sowani

Math Kangaroo 2005 Level of grades 5-6

Exercises Exercises. 1. List all the permutations of {a, b, c}. 2. How many different permutations are there of the set {a, b, c, d, e, f, g}?

COCI 2008/2009 Contest #2, 15 th November 2008 TASK KORNISLAV RESETO PERKET SVADA SETNJA CAVLI

PART 2 VARIA 1 TEAM FRANCE WSC minutes 750 points

A few chessboards pieces: 2 for each student, to play the role of knights.

Problem A. Subway Tickets

In how many ways can we paint 6 rooms, choosing from 15 available colors? What if we want all rooms painted with different colors?

Problem C The Stern-Brocot Number System Input: standard input Output: standard output

Year 6 Spring Term Week 10 to 11 Number: Ratio

Problem Set 7: Network Flows Fall 2018

COCI 2016/2017 Tasks Bridž Kartomat Kas Rekonstruiraj Rima Osmosmjerka Total

Croatian Open Competition in Informatics, contest 2 November 25, 2006

Spring 06 Assignment 2: Constraint Satisfaction Problems

Fibonacci Numbers ANSWERS Lesson 1 of 10, work individually or in pairs

Project 1: A Game of Greed

Acing Math (One Deck At A Time!): A Collection of Math Games. Table of Contents

UTD Programming Contest for High School Students April 1st, 2017

We are packing 22 balls into boxes. Show how many boxes we will need if we pack: a) 3 balls in each box b) 5 balls in each box

NRP Math Challenge Club

class TicTacToe: def init (self): # board is a list of 10 strings representing the board(ignore index 0) self.board = [" "]*10 self.

Pascal Contest (Grade 9) Wednesday, February 22, 2006

GROUP ROUND INSTRUCTIONS

Meet # 1 October, Intermediate Mathematics League of Eastern Massachusetts

wizprof Good luck and most of all have fun.! you may use 75 minutes calculators are not allowed

Math 1111 Math Exam Study Guide

Maths is all around us and we re using it every day!

2 Event is equally likely to occur or not occur. When all outcomes are equally likely, the theoretical probability that an event A will occur is:

Overview. Equipment. Setup. A Single Turn. Drawing a Domino

UCF Local Contest August 31, 2013

CS 441/541 Artificial Intelligence Fall, Homework 6: Genetic Algorithms. Due Monday Nov. 24.

a) Draw half the number of shapes in the picture. b) Draw one third of the number of shapes in the picture.

UN DOS TREZ Sudoku Competition. Puzzle Booklet for Preliminary Round. 19-Feb :45PM 75 minutes

EECS 203 Spring 2016 Lecture 15 Page 1 of 6

Discrete Mathematics: Logic. Discrete Mathematics: Lecture 15: Counting

Number Puzzles. an assortment. Author: Z. Teun Spaans Copyright: 2013

Algebra. Recap: Elements of Set Theory.

Tail. Tail. Head. Tail. Head. Head. Tree diagrams (foundation) 2 nd throw. 1 st throw. P (tail and tail) = P (head and tail) or a tail.

or More Events Activities D2.1 Open and Shut Case D2.2 Fruit Machines D2.3 Birthdays Notes for Solutions (1 page)

Homework Assignment #1

ProCo 2017 Advanced Division Round 1

UK Junior Mathematical Challenge

repeated multiplication of a number, for example, 3 5. square roots and cube roots of numbers

St Thomas of Canterbury Catholic Primary School Where every child is special

MJ DURKIN 2016 MJ DURKIN ALL RIGHTS RESERVED mjdurkinseminars.com

12.1 Practice A. Name Date. In Exercises 1 and 2, find the number of possible outcomes in the sample space. Then list the possible outcomes.

CS1800: More Counting. Professor Kevin Gold

Table of Contents. Table of Contents 1

Solving Problems. PS1 Use and apply mathematics to solve problems, communicate and reason Year 1. Activities. PS1.1 Number stories 1.

1 Stove. Task. Input. Output. Constraints

Is muddled about the correspondence between multiplication and division facts, recording, for example: 3 5 = 15, so 5 15 = 3

ACM Collegiate Programming Contest 2016 (Hong Kong)

Transcription:

TASK LJESNJAK JABUKA JAGODA LUBENICA TRESNJA KRUSKA standard standard time limit 1 second 1 second 3 seconds 1 second 1 second 1 second memory limit 32 MB 32 MB 32 MB 64 MB 64 MB 64 MB points 30 50 70 100 120 130 500

Task LJESNJAK Not so long ago, before operating systems were as powerful as they are today, computers (which often had turbo buttons on the exterior) couldn't handle certain letters of the Croatian alphabet. Programmers agreed to use two or three-letter substitutions as in this table: Letter Characters č c= ć c- dž dz= ñ d- lj lj nj nj š s= ž z= For example, the word ljes=njak consists of six letters in the Croatian alphabet: lj, e, š, nj, a, k. Write a program that calculates the number of letters in the given word. The first line contains a string of at most 100 characters. Only lowercase letters of the English alphabet and characters ' ' and '=' will appear. The string will represent a word encoded as described above. Output the number of letters in the word. dz=ak 3 ljes=njak 6

Task JABUKA Mirko has R red and G green apples to share with some of his friends, so that all of them receive the same number of red apples and also the same number of green apples. Mirko does not like apples himself so he doesn't want to be left with any apples afterward. For example, if Mirko has 4 red and 8 green apples, he can divide them in three ways: 1. One friend gets all 4 red and all 8 green apples; 2. Two friends each receive 2 red apples and 4 green apples; 3. Four friends each receive 1 red and 2 green apples. Write a program that s all ways for Mirko to divide his apples. Assume Mirko has an infinite supply of friends to give apples to. The first line contains two positive integers R and G separated by a space (1 R, G 1 000 000 000), the numbers of red and green apples. For each possible distribution, three integers N, X and Y on one line. The number N is the number of friends that will receive apples. The numbers X and Y tell how many red and greed apples each of them will receive. Each distribution needs to be exactly once. You may the distributions in any order. 4 8 1 4 8 2 2 4 4 1 2 15 12 3 5 4 1 15 12 42 105 1 42 105 3 14 35 7 6 15 21 2 5

Task JAGODA Slavko has N rabbits that he feeds every day with various fruits and vegetables. Rabbits, however, prefer strawberries above all else. Strawberries are hard to find and expensive in the middle of winter, so Slavko only gives strawberries to part of his rabbits. Slavko numbered the rabbits 1 through N. To help keep track of how many strawberries each of the rabbits got, Slavko decided on the following strawberry allocation procedure. Every day Slavko purchases some number S of strawberries and chooses some rabbit A to get the first strawberry. Rabbit A+1 will get the second strawberry, rabbit A+2 the third etc. Every rabbit is assigned an initially empty matchbox, the N matchboxes forming a single row. Let K be the largest integer such that K K N. Every group of K matchboxes (starting with the first) will also have a cup next to them. We say that K consecutive matchboxes with their cup form a block. After giving the rabbits their strawberries, Slavko will put a single match into the matchbox of every rabbit that got a strawberry, unless he would be putting a match into all matchboxes in a block. Instead of putting matches into all matchboxes in a block, he will put a single match in the appropriate cup. The total number of strawberries received by a rabbit can be calculated as the number of matches in its matchbox plus the number of matches in its cup. For example, assume that there are 11 rabbits, that is N=11. The number three is the largest integer which, when squared, gives a result of at most 11, so K=3. There will be four blocks, the last of them incomplete with only two matchboxes. If Slavko buys 6 strawberries and gives the first of them to rabbit 5, the state in the cups and matchboxes will be: Write a program that simulates the above procedure, knowing the number of rabbits N, the number of days M and the numbers S and A for each of the M days. For every day, the total number of matches in all matchboxes and cups that Slavko added matches to on that day.

Task JAGODA The first line contains the integers N and M separated by a space (1 N, M 100 000), the number of rabbits and days. Each of the following M lines contains two integers S and A separated by a space. These numbers mean that Slavko purchased S strawberries that day and that rabbit A will receive the first one (1 A N, 1 A+S 1 N). Output M numbers, each on a separate line. The k-th line should contain the total number of matches in all matchboxes and cups that Slavko used on day k. 11 3 6 5 3 1 11 1 4 1 6 16 3 2 2 12 3 6 11 2 7 3 In the first example, there are 11 rabbits and matchboxes, and four blocks, as shown in the image on the previous page. 1. On the first day, Slavko gives strawberries to rabbits 5 through 10, putting matches into matchboxes 5, 6 and 10, and one into the third cup. Before this there were no other matches in the matchboxes and cups he used, so the is four. 2. On the second day, Slavko gives strawberries to rabbits 1 through 3, putting just one match into the first cup. 3. On the third day, Slavko gives strawberries to all his rabbits, putting one match into every cup. After putting the four matches into cups, there is a total of six matches in the cups he used, so the is six.

Task LUBENICA Children in school are having fun instead of listening to the teacher. With their iphone devices the children throw watermelons at each other on the Facebook social site. The game started when Goran threw one watermelon at each of his friends during the first class that day. During subsequent classes, all children (including Goran) behaved like this: If they had been hit by an odd number of watermelons during the previous class, they threw exactly one watermelon at each of their friends; If they had been hit by an even number of watermelons (including zero), then they hit each of their friends with two watermelons. The children are numbered 1 through N, Goran obviously being number 1. The friend relationships between the children are also known. Write a program that will calculate the total number of watermelons thrown after H classes. The first line contains two integers N and H (1 N 20, 1 H 1 000 000 000), the number of kids and classes. Each of the following N lines contains a string of N characters '0' or '1'. The character (A, B) in this matrix is '1' if children A and B are friends. No child will be their own friend. The matrix will be symmetric. Output the number of watermelons after H classes. SCORING In test cases worth 50% of points, H will be at most 1000. 4 1 0110 1001 1001 0110 2 4 2 0110 1001 1001 0110 14 5 3 01000 10110 01000 01001 00010 26 In the second example, Goran throws two watermelons during the first class. During the second class, children 1 and 4 each throw two watermelons at 2 and 3 each, while 2 and 3 throw one watermelon at 1 and 4. A total of 12 watermelons is thrown during the second class.

Task TRESNJA Lana lives in a small but merry village. There is a row of cherry trees next to the main street. Lana numbered the trees with consecutive integers starting with 1. After much studying, Lana noticed that the number of the tree uniquely determines the amount of cherries the tree gives. For one tree, consider consecutive groups of digits in the tree's number. For each group of digits, multiply the digit by the square of the length of the group. Adding these numbers for all groups gives the total number of cherries the tree gives. For example, in tree number 77744007, the groups are 777, 44, 00 and 7. The amount of cherries will be 7 3 2 + 4 2 2 + 0 2 2 + 7 1 2 = 86 units. The time has come to pick the cherry trees and the villagers have agreed to pick all trees numbered A through B (inclusive). Write a program that will calculate the total amount of cherries picked. Input consists of two integers A and B (1 A B 10 15 ), the first and last trees to be picked. Output a single integer, how many units of cherries will be picked. 1 9 45 100 111 68 7774407 7774407 86

Task KRUSKA Aladdin has become bored of life at the palace. He has a steady job, his wife Jasmine, kids are on the way and life is becoming monotonous. Prompted by all this, he has decided to have one more adventure before settling down. He has decided to find the Golden Pear, an extremely valuable legendary artifact that no one has been able to find. The desert Aladdin is searching is can be modeled as an N N grid of cells. Rows and columns are numbered 1 through N top to bottom and left to right. Some of the cells in the desert contain wizards that help Aladdin's quest in an unusual way. Aladdin starts his quest in the top left corner of the desert on a Monday facing right. His movement involves repeating these steps: 1. If the current cell contains a wizard that is awake, then Aladdin turns 90 degrees left or right, depending on what the wizard says. 2. If moving forward would take Aladdin out of desert, he turns 180 degrees. 3. Aladdin moves forward one cell and it takes him exactly one day. For each wizard we know his location and his activity schedule for each day of the week. The schedule is a string of exactly seven letters 'L', 'R' or 'S', each character telling us what the wizard does on one day of the week (starting with Monday). The letter 'L' means that Aladdin will be told to turn left, 'R' that Aladdin will be told to turn right, while 'S' means the wizard sleeps that day. An old prophecy says that after K changes in direction (in steps 1 and/or 2) Aladdin will find the Pear. Write a program that calculates how many days the search will last, according to the ancient prophecy. The first line contains two integers N and K (2 N 200, 1 K 1 000 000 000), the size of the desert and the number of direction changes in the prophecy. The second line contains an integer M (0 M 10 000), the number of wizards. Each of the following M lines contains two integers R and C (1 R, C N), and a string of seven letters 'L', 'R' or 'S'. The numbers represent the row and column where the wizard is located, while the string is his schedule. No two wizards will share the same cell, nor will there be a wizard in cell (1, 1). Output the length of the search in days. SCORING In test cases worth 50% of points, K will be at most 1000.

Task KRUSKA 3 1 0 2 5 2 2 1 3 RRSRRRR 1 5 RRRRLRR 4 5 5 3 1 3 SSRSSSS 3 3 SSSLSSS 4 3 SSRSSLS 10 In the first example, Aladdin moves twice, reaching the edge of the desert. He then turns 180 degrees and finds the Pear. In the second example, Aladdin reaches the first wizard on the third day, but the wizard is sleeping so Aladdin continues in the same direction. After two more days he reaches the other wizard who tells him to turn left. Aladdin does so, reaches the edge of the desert, turns back and finds the pair.