Problem A - Complete the sequence

Similar documents
ACM-ICPC Indonesia National Contest Problem A. The Best Team. Time Limit: 2s

Recursion Problems. Warm Ups. Enumeration 1 / 7

Finite Math - J-term Homework. Section Inverse of a Square Matrix

4 KARNAUGH MAP MINIMIZATION

(Refer Slide Time: 00:01:30)

XVIII Open Cup named after E.V. Pankratiev Stage 1: Grand Prix of Romania, Sunday, September 17, 2017

Math 574 Review Exam #1

The Partitioning Problem

[key, Left subtree, Right subtree]

A B C D E F. = 1/3 1 divided by 3, that is, The product of cells A2 and C12. Cell C6 divided by the difference of D4 and E4

Repetition Through Recursion

2015 ICPC. Northeast North America Preliminary

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17

Slide Set 5. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

第六屆 ACM ICPC 全國私立大專校院程式競賽. National Contest for Private Universities, Taiwan 2016 競賽題目

Section 1.2 Fractions

IT 201 Digital System Design Module II Notes

Greedy Algorithms CHAPTER 16

EE 368. Weeks 5 (Notes)

Math 9 Final Exam Review and Outline

The Further Mathematics Support Programme

Midterm practice problems

D-Optimal Designs. Chapter 888. Introduction. D-Optimal Design Overview

If m = f(m), m is said to be perfect; if m < f(m), m is said to be abundant; if m > f(m), m is said to be deficient.

Lecture 5. Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs

String Matching. Pedro Ribeiro 2016/2017 DCC/FCUP. Pedro Ribeiro (DCC/FCUP) String Matching 2016/ / 42

More About Factoring Trinomials

Memory Addressing, Binary, and Hexadecimal Review

Basics of Computational Geometry

Section 1.8. Simplifying Expressions

Subject: Computer Science

Lecture 6,

2016 ACM ICPC Southeast USA Regional Programming Contest. Division 1

Grade 7 Mensuration - Perimeter, Area, Volume

Problem A - EPIC. Line Width of Letters (# characters) EEEEEEEEEE EEEEEEEEEE EE EE EEEEEEEEEE EEEEEEEEEE EE EE EEEEEEEEEE EEEEEEEEEE

B-Trees and External Memory

Solutions to Problem Set 3

Project 2: How Parentheses and the Order of Operations Impose Structure on Expressions

? Answer:

Skill 1: Multiplying Polynomials

B-Trees and External Memory

MITOCW watch?v=w_-sx4vr53m

Lecture 25 : Counting DRAFT

Lesson 4.02: Operations with Radicals

MITOCW watch?v=4dj1oguwtem

A Bullseye. Problem. Output. For each dataset, print a line of the form: SCORE: N to M, PLAYER P WINS. Or: SCORE: N to M, TIE.

Introduction to Scientific Computing

CSE100. Advanced Data Structures. Lecture 8. (Based on Paul Kube course materials)

II. Functions. 61. Find a way to graph the line from the problem 59 on your calculator. Sketch the calculator graph here, including the window values:

Lecture 3, Review of Algorithms. What is Algorithm?

Greedy Algorithms. Previous Examples: Huffman coding, Minimum Spanning Tree Algorithms

Integers and Mathematical Induction

Scribe: Virginia Williams, Sam Kim (2016), Mary Wootters (2017) Date: May 22, 2017

Formatting for TLM - Part I

Design and Analysis of Algorithms

Chapter 3, Algorithms Algorithms

Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi.

Slide 2 / 222. Algebra II. Quadratic Functions

Indiana State Math Contest Geometry

Chapter 1: Number and Operations

REVIEW. The C++ Programming Language. CS 151 Review #2

: Fundamental Data Structures and Algorithms. June 06, 2011 SOLUTIONS

Algorithms Assignment 3 Solutions

2016 AMC 10A. x rem(x,y) = x y y. . What is the value of rem( 3 8, 2 5 )? (A) 3 8. denotes the greatest integer less than or equal to x y

Graphing Linear Equations Review

[Y2] Counting and understanding number. [Y2] Counting and understanding number. [Y2] Counting and understanding number

Assignment 5 Files, Linked Lists, and Binary Search Trees

Week - 04 Lecture - 01 Merge Sort. (Refer Slide Time: 00:02)

4&5 Binary Operations and Relations. The Integers. (part I)

MATHEMATICS (SYLLABUS D) 4024/02

CS 206 Introduction to Computer Science II

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

EOC Review: Practice: 1. In the circle below, AB = 2BC. What is the probability of hitting the shaded region with a random dart?

Data Warehousing and Data Mining

All answers must be clearly indicated on your ANSWER SHEET. Please print your name and the name of your school in full on your ANSWER SHEET.

Bit Hacks Project 1. Last Updated: October 3, 2010

UNC Charlotte 2010 Comprehensive

Math 2 Coordinate Geometry Part 2 Lines & Systems of Equations

CS15100 Lab 7: File compression

Introduction to Counting, Some Basic Principles

Chapter 2 Combinational Logic Circuits

But I know what most of you will do: use a calculator to convert; that's fine, IF you understand the theory.

Math 4. Class work 2. Algebra. Sets.

Engineering Mechanics Prof. Siva Kumar Department of Civil Engineering Indian Institute of Technology, Madras Statics - 4.3

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex

CS 411 Analysis of Algorithms, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Wednesday, October 17, 2012.

4 ' MATHCOUNTS National Competition Sprint Round Problems 1-30 DO NOT BEGIN UNTIL YOU ARE INSTRUCTED TO DO SO.

Exam : C : IBM InfoSphere Quality Stage v8 Examination. Title. Version : DEMO

ACM ICPC 2012, qualification round

You can write a command to retrieve specified columns and all rows from a table, as illustrated

[A] The Earth is Flat!

* Due 11:59pm on Sunday 10/4 for Monday lab and Tuesday 10/6 Wednesday Lab

TOURNAMENT OF THE TOWNS, Glossary

Data Analysis and Solver Plugins for KSpread USER S MANUAL. Tomasz Maliszewski

(Refer Slide Time: 01.26)

LESSON 1: INTRODUCTION TO COUNTING

CGF Lecture 2 Numbers

Greedy Algorithms and Huffman Coding

Most nonzero floating-point numbers are normalized. This means they can be expressed as. x = ±(1 + f) 2 e. 0 f < 1

Principles of Algorithm Design

Transcription:

Problem A - Complete the sequence You probably know those quizzes in Sunday magazines: given the sequence 1, 2, 3,,, what is the next number? Sometimes it is very easy to answer, sometimes it could be pretty hard. Because these sequence problems are very popular. Notice that some of the quizzes can be solved by describing the sequence by polynomials. For example, the sequence 1, 2, 3,, can be easily understood as a trivial polynomial. The next number is 6. But even more complex sequences, like 1, 2,, 7, 11, can be described by a polynomial. In this case, 1/2 n 2-1/2 n + 1 can be used. Note that even if the members of the sequence are integers, polynomial coefficients may be any real numbers. There is a single positive integer N (<120) on the first line of input. It stands for the number of test cases to follow. Each test case consists of two lines. First line of each test case contains two integer numbers S and C separated by a single space, 1 S < 100, 1 C < 100, S + C 100. The first number, S, stands for the length of the given sequence, the second number, C is the amount of numbers you are to find to complete the sequence. The second line of each test case contains S integers X 1, X 2,..., X S separated by a space. These numbers form the given sequence. The sequence can always be described by a polynomial P(n) such that for every i, X i = P(i). Among these polynomials, you should find the polynomial with the lowest possible degree. This polynomial should be used for completing the sequence. For every test case, your program must print a single line containing C integers, separated by a space. These numbers are the values completing the sequence according to the polynomial of the lowest possible degree. In other words, you should print values P(S+1), P(S+2),..., P(S+C). It is guaranteed that all the integers of the input and output are non-negative and will fit into the standard integer type. 6 3 1 2 3 6 8 2 1 2 7 11 16 22 29 10 2 1 1 1 1 1 1 1 1 1 2 1 10 3 7 8 9 37 6 11 6 3 3 3 3 3 3 3 3 3 3

Problem B - Transmitters In a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don't overlap, or at least that they don't conflict. One way of accomplishing this is to restrict a transmitter s coverage area. This problem uses a shielded transmitter that only broadcasts in a semicircle. A transmitter T is located somewhere on a 1,000 square meter grid. It broadcasts in a semicircular area of radius r. The transmitter may be rotated any amount, but not moved. Given N points anywhere on the grid, compute the maximum number of points that can be simultaneously reached by the transmitter's signal. Figure 1 shows the same data points with two different transmitter rotations. All input coordinates are integers (0-1000). The radius is a positive real number greater than 0. Points on the boundary of a semicircle are considered within that semicircle. There are at most 10 unique points to examine per transmitter. No points are at the same location as the transmitter. consists of information for one or more independent transmitter problems. Each problem begins with one line containing the (x, y) coordinates of the transmitter followed by the broadcast radius, r. The next line contains the number of points N on the grid, followed by N sets of (x, y) coordinates, one set per line. The end of the input is signaled by a line with a negative radius. Figures 1 and 2 represent the data in the first two example data sets below, though they are on different scales. Figures 1a and 2 show transmitter rotations that result in maximal coverage. There will be at most 0 test cases. For each transmitter, the output contains a single line with the maximum number of points that can be contained in some semicircle. 2 2 3. 7 2 28 23 27 27 27 2 23 26 23

2 29 26 29 30 200 2.0 30 202 30 199 30 198 38 200 32 200 99 99 10.0 1000 1000 999 998 990 992 1000 999 100 100-2. 3

Problem C Sorting It All Out An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence A, B, C, D implies that A < B, B < C and C < D. In this problem, we will give you a set of relations of the form A < B and ask you to determine whether a sorted order has been specified or not. consists of multiple problem instances. Each instance starts with a line containing two positive integers n and m. The first value indicates the number of objects to sort, where 2 n 26. The objects to be sorted will be the first n characters of the uppercase alphabet. The second value m indicates the number of relations of the form A<B which will be given in this problem instance. Next will be m lines, each containing one such relation consisting of three characters: an uppercase letter, the character < and a second uppercase letter. No letter will be outside the range of the first n letters of the alphabet. Values of n = m = 0 indicate end of input. There will be at most 110 test cases. For each problem instance, output consists of one line. This line should be one of the following three: Sorted sequence determined after xxx relations: yyy...y. Sorted sequence cannot be determined. Inconsistency found after xxx relations. where xxx is the number of relations processed at the time either a sorted sequence is determined or an inconsistency is found, whichever comes first, and yyy...y is the sorted, ascending sequence. Sample 6 A<B A<C B<C C<D B<D A<B 3 2 A<B B<A 26 1 A<Z 0 0 Sample Sorted sequence determined after relations: ABCD. Inconsistency found after 2 relations. Sorted sequence cannot be determined.

Problem D - Trees Made to Order We can number binary trees using the following scheme: The empty tree is numbered 0. The single-node tree is numbered 1. All binary trees having m nodes have numbers less than all those having m + 1 nodes. Any binary tree having m nodes with left and right subtrees L and R is numbered n such that all trees having m nodes numbered greater than n have either a left subtrees numbered higher than L, or a left subtree = L and a right subtree numbered higher than R. The first 10 binary trees and tree number 20 in this sequence are shown below: 0 1 2 3 6 7 8 9... 20 X X X X X X X X X X \ / \ \ / \ / / \ / X X X X X X X X X X \ / \ / \ / \ X X X X X X X \ X Your job for this problem is to output a binary tree when given its order number. consists of multiple problem instances. Each instance consists of a single integer n, where 1 n 00, 000, 000. A value of n = 0 terminates input. (Note that this means you will never have to output the empty tree.) There will be at most 200 test cases. For each problem instance, you should output one line containing the tree corresponding to the order number for that instance. To print out the tree, use the following scheme: A tree with no children should be output as X. A tree with left and right subtrees L and R should be output as (L )X(R ), where L and R are the representations of L and R. If L is empty, just output X(R ). If R is empty, just output (L )X. 1 20 3111732 0 X ((X)X(X))X (X(X(((X(X))X(X))X(X))))X(((X((X)X((X)X)))X)X)

Problem E No Change Though it might be hard to imagine, the inhabitants of a small country Additivia do not know of such thing as change, which probably has to do with them not knowing subtraction either. When they buy something, they always need to have the exact amount of addollars, their currency. The only other option, but not a really attractive one, is over-paying. Professor Adem, one of the Additivian mathematicians came up with an algorithm for keeping a balanced portfolio. The idea is the following. Suppose you have more coins of value v 1 than coins of value v 2. In this case you should try to spend at least as many coins of value v 1 as those of value v 2 on any buy you make. Of course spending too many v 1 coins is not a good idea either, but to make the algorithm simpler professor Adem decided to ignore the problem. The algorithm became an instant hit and professor Adem is now designing a kind of electronic portfolio with built-in Adem's algorithm. All he needs now is a software for these machines, that will decide whether a given amount of addollars can be paid using a given set of coins according to the rules of Adem's algorithm. Needless to say, you are his chosen programmer for the task. Write a program that reads the description of a set of coins and an amount of addollars to be paid, and determines whether you can pay that amount according to Professor Adem's rules. The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. The input starts with the amount of addollars to be paid x, where 1 x 100000. The number of different coin values k follows, where 1 k. The values of the coins v 1,..., v k follow, where 1 v i 10000. Notice that the order among coin values is significant: you need to spend at least as many coins of value v 1 as coins of value v 2, at least as many coins of value v 2 as those of value v 3, and so on. You may assume that you have a sufficiently large number of coins of each value. There will be at most 100 test cases. For each test case, your program should output either a single word YES, if the given amount can be paid according to the rules, or a single word NO otherwise. 2 13 3 9 2 1 11 1 3 7 NO YES

Problem F Pairs of integers You are to find all pairs of integers such that their sum is equal to the given integer number N and the second number results from the first one by striking out one of its digits. The first integer always has at least two digits and starts with a non-zero digit. The second integer always has one digit less than the first integer and may start with a zero digit. The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them consists of a single integer N where 10 N 1,000,000,000). There will be at most 200 test cases. For each test case, the output must follow the description below. On the first line, write the total number of different pairs of integers that satisfy the problem statement. On the following lines, write all those pairs. Write one pair on a line in ascending order of the first integer in the pair. Each pair must be written in the following format: X + Y = N Here X, Y, and N, must be replaced with the corresponding integer numbers. There should be exactly one space on both sides of + and = characters. 10 11 302 1002 1666 Sample Onput 1 10 + 0 = 10 1 10 + 1 = 11 21 + 1 = 302 27 + 27 = 302 276 + 26 = 302 281 + 21 = 302 301 + 01 = 302 906 + 96 = 1002 911 + 91 = 1002 91 + 1 = 1002 1001 + 001 = 1002 12333 + 2333 = 1666 12833 + 1833 = 1666 13283 + 1383 = 1666 13328 + 1338 = 1666 13333 + 1333 = 1666