ACM Programming Contest Problem 1 For this problem you are to write a program that takes as input two numbers which are the base and height of a rectangle, Your program should print out the border of the rectangle using +, and the inside using =. The base and the height will be at most 20. Example: Input: 6 4 Output: ++++++ +====+ +====+ ++++++ Input: 3 2 Output: +++ +++ ACM Programming Contest Problem 2 Write a program which accepts as input a string of up to 40 lower case letters and produces two lines of output. The first line has all the vowels (a,e,i,o,u) in the input string in the order they appeared. The second line has all the non-vowels in the REVERSE order to which they appeared. The vowels appear forwards and the consonants appear backwards. Example: INPUT: naturally OUTPUT: aua yllrtn ACM-Programming Contest Problem 3 A world archery competition has commissioned you to write a scoring program. The target computer reports the point of impact as an (X,Y) pair. It also reports the coordinate for the center of the target as an (X,Y) pair (not all of the targets re equally aligned!). All X and Y will be between 0 and 50. The target has 5 concentric rings. The bull's-eye has radius 10 and each successive ring increases the radius by 5. The bull's-eye scores 9 and each successive ring scores 2 less. Missing the target scores 0. Assume that impacts on a boundary line between two rings score the lower of the two scores. Thus: Input is what the target computer reports: center: X = 31, Y = 32 impact point: X = 35, Y = 49 Your program , given this information, would print "The score is 5." Input for your program will be two lines with two number on each line. The number on the first line is the center point and the number on the second line is the impact point. Output is the score. Examples: INPUT: 0 0 5 12 OUTPUT: The score is 7. INPUT: 1 1 40 40 OUTPUT: The score is 0. Recall that the square of the distance between two points (X1,Y1) and (X2,Y2) is (X2-X1)(X2-X1)+(Y2-Y1)(Y2-Y1). ACM Programming Contest Problem 4 Describing Sequences The following sequence of positive integers is generated by a rule which tells how each number is determined from the previous number. The rule is not obvious and will be explained below. 1 11 21 1211 111221 312211 13112221 1113213211 and so on. To determine the next number in the sequence proceed as follows: 1. Read the current number as a string of digits from left to right. 2. Describe the string by writing down the number of consecutive occurrences of an encountered digit followed by that digit. 3. Repeat step 2. as you read from left to right. For example the first number in the sequence above could be anything but we chose 1. Reading that first number from left to right we see one 1. Hence the second number is 11 (one 1). Reading that second number from left to right we see two 1's. Hence the third number is 21 (two 1's). Reading the third number we see one 2 and then one 1. Hence the fourth number is 1211 (one 2 and one 1). Reading that we see one 1, one 2, and two 1's. Remember that we accumulate the last two 1's and don't describe them separately. So the next number is 111221. PROBLEM: You are to write a program that accepts as INPUT a string of up to 20 digits between 1 and 3 and having an even number of digits. Your program is to produce as OUTPUT two strings. The first should be the PREVIOUS string is the sequence - i.e. the string described by the input string. The second output should be the NEXT string in the sequence - i.e. the string describing the input string. EXAMPLE: INPUT: 312211 OUTPUT: 111221 13112221 Ask if you can't understand how the sequence is generated. ACM Programming Contest Problem 5 Consider a two dimensional array of cells, each of which may be either full or empty. Any group of full cells which are connected horizontally or vertically (but NOT diagonally) is said to constitute a "blob". For example, in the array shown bellow, there are three blobs. ------------------- | 1 | | | | | ------------------- | | 1 | 1 | 1 | 1 | ------------------- | 1 | | 1 | | 1 | ------------------- | 1 | | | | 1 | ------------------- | | 1 | 1 | 1 | 1 | ------------------- PROBLEM ------- You are to write a program which inputs an N x N array of binary values and outputs the number of blobs in that array. The value of N is also to be an input to the program. Your program will first prompt the user for a value of N. You may assume that N will not exceed 50 for the purposes of this contest. After reading N, the program will input N lines of N 0's or 1's that represent the N x N array. The 0's and 1's are separated by spaces, so the input for the example above would be as follows: 1 0 0 0 0 0 1 1 1 1 1 0 1 0 1 1 0 0 0 1 0 1 1 1 1 All inputs will come from the keyboard.