Showing posts with label Volume IV. Show all posts
Showing posts with label Volume IV. Show all posts

Solution of 401 - Palindromes

Problem Description
source:https://uva.onlinejudge.org/external/4/401.html

A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string “ABCDEDCBA” is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left. A mirrored string is a string for which when each of the elements of the string is changed to its reverse (if it has a reverse) and the string is read backwards the result is the same as the original string. For example, the string “3AIAE” is a mirrored string because ‘A’ and ‘I’ are their own reverses, and ‘3’ and ‘E’ are each others’ reverses. A mirrored palindrome is a string that meets the criteria of a regular palindrome and the criteria of a mirrored string. The string “ATOYOTA” is a mirrored palindrome because if the string is read backwards, the string is the same as the original and because if each of the characters is replaced by its reverse and the result is read backwards, the result is the same as the original string. Of course, ‘A’, ‘T’, ‘O’, and ‘Y’ are all their own reverses. A list of all valid characters and their reverses is as follows.

Solution of 406 - Prime Cuts

Problem Description
source:https://uva.onlinejudge.org/external/4/406.html

A prime number is a counting number (1, 2, 3, . . .) that is evenly divisible only by 1 and itself. In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between (and including) 1 and N. Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the 2C prime numbers from the center of the list if there are an even number of prime numbers or 2C − 1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

Input 

Each input set will be on a line by itself and will consist of 2 numbers. The first number (1 ≤ N ≤ 1000) is the maximum number in the complete list of prime numbers between 1 and N. The second number (1 ≤ C ≤ N) defines the 2C prime numbers to be printed from the center of the list if the length of the list is even; or the 2C − 1 numbers to be printed from the center of the list if the length of the list is odd.

image

Solution of 483 - Word Scramble

Problem Description
source:https://uva.onlinejudge.org/external/4/483.html

Write a program that will reverse the letters in each of a sequence of words while preserving the order of the words themselves. 

Input 

The input file will consist of several lines of several words. Words are contiguous stretches of printable characters delimited by white space. 

image

Solution of 424 - Integer Inquiry

Problem Description
source: https://uva.onlinejudge.org/external/4/424.html

One of the first users of BIT’s new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers. 
     “This supercomputer is great,” remarked Chip. “I only wish Timothy were here to see these results.” (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.)

Input 

The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative). 
     The final input line will contain a single zero on a line by itself

image

Solution of 494 - Kindergarten Counting Game

Problem Description
source: https://uva.onlinejudge.org/external/4/494.html

Everybody sit down in a circle. Ok. Listen to me carefully. 
     “Woooooo, you scwewy wabbit!”

 Now, could someone tell me how many words I just said?

Input 

Input to your program will consist of a series of lines, each line containing multiple words (at least one). A “word” is defined as a consecutive sequence of letters (upper and/or lower case). 

image

Solution of 458 - The Decoder

Problem Description
source: https://uva.onlinejudge.org/external/4/458.html

Write a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact message that the characters contain. The code key for this simple coding is a one for one character substitution based upon a single arithmetic manipulation of the printable portion of the ASCII character set.

Input and Output 

For example: with the input file that contains: 

1JKJ'pz'{ol'{yhklthyr'vm'{ol'Jvu{yvs'Kh{h'Jvywvyh{pvu5 
1PIT'pz'h'{yhklthyr'vm'{ol'Pu{lyuh{pvuhs'I|zpulzz'Thjopul'Jvywvyh{pvu5 
1KLJ'pz'{ol'{yhklthyr'vm'{ol'Kpnp{hs'Lx|pwtlu{'Jvywvyh{pvu5 

image

Solution of 445 - Marvelous Mazes

Problem Description
source: https://uva.onlinejudge.org/external/4/445.html

Your mission, if you decide to accept it, is to create a maze drawing program. A maze will consist of the alphabetic characters A-Z, * (asterisk), and spaces.

Input 

Your program will get the information for the mazes from the input file. This file will contain lines of characters which your program must interpret to draw a maze. Each row of the maze will be described by a series of numbers and characters, where the numbers before a character tell how many times that character will be used. If there are multiple digits in a number before a character, then the number of times to repeat the character is the sum of the digits before that character. 
    The lowercase letter ‘b’ will be used in the input file to represent spaces in the maze. The descriptions for different rows in the maze will be separated by an exclamation point (!), or by an end of line. 
    Descriptions for different mazes will be separated by a blank line. The input file will be terminated by an end of file.  

image