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

Solution of 11933 - Splitting Numbers

Problem Description
source:https://uva.onlinejudge.org/external/119/11933.html

We define the operation of splitting a binary number n into two numbers a(n), b(n) as follows. Let 0 ≤ i1 < i2 < . . . < ik be the indices of the bits (with the least significant bit having index 0) in n that are 1. Then the indices of the bits of a(n) that are 1 are i1, i3, i5, . . . and the indices of the bits of b(n) that are 1 are i2, i4, i6, . . .
For example, if n is 110110101 in binary then, again in binary, we have a = 010010001 and b = 100100100.


Solution of 11995 - I Can Guess the Data Structure!

Problem Description
source:https://uva.onlinejudge.org/external/119/p11995.pdf

There is a bag-like data structure, supporting two operations: 

1 x      Throw an element x into the bag. 
2         Take out an element from the bag. 

Given a sequence of operations with return values, you’re going to guess the data structure. It is a stack (Last-In, First-Out), a queue (First-In, First-Out), a priority-queue (Always take out larger elements first) or something else that you can hardly imagine! 

Solution of 11984 - A Change in Thermal Unit

Problem Description
source:https://uva.onlinejudge.org/external/119/p11984.html

Measuring temperature and temperature differences are common task in many research and applications. Unfortunately, there exists more than one unit of measuring temperatures. This introduces a lot of confusion at times. Two popular units of measurements are Celsius(C) and Fahrenheit (F). The conversion of F from C is given by the formula

                             F = (9 / 5) * C + 32

In this problem, you will be given an initial temperature in C and an increase in temperature in F. You would have to calculate the new temperature in C.

image

Solution of 11970 - Lucky Numbers

Problem Description
source:https://uva.onlinejudge.org/external/119/p11970.html

Every person has its own numbers that he considers lucky. Usually the numbers are fixed like 3 or 7 and do not depend on anything. This lucky number model seems to be very primitive for John, so he decided to upgrade it for his own use. Maybe more complex model will bring more luck to him? John has added a dependency for lucky numbers on specific integer N (for example N can be ordinal number of day in year or some other meaning). For each N John considers some number X lucky if and only if fraction X/√( N − X) value is integer and greater than zero. 

Input 

The number of tests T (T ≤ 100) is given on the first line. T lines follow, each of them contains one integer N (1 ≤ N ≤ 109 ) described above. 

image

Solution of 11965 - Extra Spaces

Problem Description
source:https://uva.onlinejudge.org/external/119/p11965.html

In programming multiple whitespaces are used to only to make code more readable, so mostly all programming languages totally ignore multiple spaces in code (except for some esoteric ones). In general there are different types of whitespace characters: space itself, tabs, newline symbol, various control characters, etc. Tabs and spaces bring one or the biggest holywar to a programmers world as there is no common rule what to use for code indentation — tab or space characters. In this holywar you stand for tab side and your project code convention requires to use only them for code indentation. However you have recently spotted that someone is using space characters instead of it. Four spaces and tab character look the same in our text editor, so you have decided to write a parser that will change all consequent space characters to one. After that you would be able to determine amount of corrupted code.

image

Solution of 11946 - Code Number

Problem Description
source:https://uva.onlinejudge.org/external/119/p11946.html

Adrian and Maria are relatives that live in different towns. As they inhabit a rural area, it is very difficult for them to keep in touch. One way they found to overcome their communication problem was to send a line through their parents that used to visit each other.

 The point is that Adrian and Maria did not want that their parents read their messages, and they decided to create a secret code for the messages. The code is not very sophisticated, but you should keep in mind Adrian and Maria are just children. 

In general, the meaning of a message is based on changing some letters by numbers. Each message is composed by several lines using uppercase letters of the English alphabet, space and punctuation symbols: dot and comma. The letters that are changed by numbers can be seen in the following example; this change is the same for all messages between Adrian and Maria. 

Message in “Code Number”:

image

Solution of 11942 - Lumberjack Sequencing

Problem Description
source:https://uva.onlinejudge.org/external/119/p11942.html

Another tale of lumberjacks?. Let see . . . 

The lumberjacks are rude, bearded workers, while foremen tend to be bossy and simpleminded. The foremen like to harass the lumberjacks by making them line up in groups of ten, ordered by the length of their beards. The lumberjacks, being of different physical heights, vary their arrangements to confuse the foremen. Therefore, the foremen must actually measure the beards in centimeters to see if everyone is lined up in order. 

Your task is to write a program to assist the foremen in determining whether or not the lumberjacks are lined up properly, either from shortest to longest beard or from longest to shortest. 

Input 

image

Solution of 11936 - The Lazy Lumberjacks

Problem Description
source:https://uva.onlinejudge.org/external/119/11936.html

Once upon a time in a far, far away forest, there was a team of lazy lumberjacks. Since they were too lazy to cut trees, they were always figuring out ways to sneak out of work. Their foreman, on the other side, was always trying to put them all to work. 
After a lot of discussions the foreman and the lumberjacks came to an agreement: they will work, but only if the area of the forest assigned to each one was a triangle. If it was any other shape they will be free not to work that week. The idea was to give each lumberjack three numbers representing the length of each of the triangles side. If the numbers were correct and form a triangle, the lumberjacks had to work, else, they were free to leave and not work. 
Since our lumberjacks are as cunning as they are lazy, they convince the foreman to let them determine the surface and the site in the forest were they will work. As a result, the lumberjacks keep passing the foreman sets of numbers that could not form the sides of a triangle. After a while, the foreman began to suspect and decide to write a program that validates the input of each lumberjack. Now when the lumberjacks decide to pass wrong numbers they get a fine of $1000.00 (more than a day’s salary). Your job is to write the program that the foreman has to use to determine if the numbers (all integers) passed by the lumberjacks can be the sides of a triangle. If they can, you have to print ‘OK’ else you have to print ‘Wrong!!

image

Solution of 11934 - Magic Formula

Problem Description
source: https://uva.onlinejudge.org/external/119/p11934.html

You are given a quadratic function, 
                           f(x) = ax2 + bx + c 
You are also given a divisor d and a limit L. How many of the function values f(0), f(1), . . . , f(L) are divisible by d? 

Input

 Input consists of a number of test cases. Each test case consists of a single line containing the numbers a b c d L (−1000 ≤ a, b, c ≤ 1000, 1 < d < 1000000, 0 ≤ L < 1000). 
Input is terminated by a line containing ‘0 0 0 0 0’ which should not be processed.