Algorithm of 11364 - Parking

Problem Description Link
Algorithm:
It is a simple problem this problem says that
When shopping on Long Street, Michael usually parks his car at some random location,
and then walks to the stores he needs. Can you help Michael choose a place to park which minimizes the distance he needs to walk on his shopping round?

Now you can follow this technique to solve this problem

image

Solution of 11364 - Parking

Problem Description
source:https://uva.onlinejudge.org/external/113/11364.html

When shopping on Long Street, Michael usually parks his car at some random location, and then walks to the stores he needs. Can you help Michael choose a place to park which minimises the distance he needs to walk on his shopping round? 
           Long Street is a straight line, where all positions are integer. You pay for parking in a specific slot, which is an integer position on Long Street. Michael does not want to pay for more than one parking though. He is very strong, and does not mind carrying all the bags around.

Input 

The first line of input gives the number of test cases, 1 ≤ t ≤ 100. There are two lines for each test case. The first gives the number of stores Michael wants to visit, 1 ≤ n ≤ 20, and the second gives their n integer positions on Long Street, 0 ≤ xi ≤ 99.

Solution of 11332 - Summing Digits

Problem Description
source:https://uva.onlinejudge.org/external/113/11332.html

For a positive integer n, let f(n) denote the sum of the digits of n when represented in base 10. It is easy to see that the sequence of numbers n, f(n), f(f(n)), f(f(f(n))), . . . eventually becomes a single digit number that repeats forever. Let this single digit be denoted g(n). 
For example, consider n = 1234567892. Then: 

    f(n) = 1+2+3+4+5+6+7+8+9+2 = 47 
    f(f(n)) = 4 + 7 = 11 
    f(f(f(n))) = 1 + 1 = 2 
    Therefore, g(1234567892) = 2. 

Solution of 11192 - Group Reverse

Problem Description
source:https://uva.onlinejudge.org/external/111/11192.html

Group reversing a string means reversing a string by groups. For example consider a string:   
    “TOBENUMBERONEWEMEETAGAINANDAGAINUNDERBLUEICPCSKY” This string has length 48. We have divided into 8 groups of equal length and so the length of each group is 6. Now we can reverse each of these eight groups to get a new string: 

“UNEBOTNOREBMEEMEWENIAGATAGADNAEDNUNIIEULBRYKSCPC” Given the string and number of groups in it, your program will have to group reverse it. 

Input 

The input file contains at most 101 lines of inputs. Each line contains at integer G (G < 10) which denotes the number of groups followed by a string whose length is a multiple of G. The length of the string is not greater than 100. The string contains only alpha numerals. Input is terminated by a line containing a single zero. 

image

Solution of 11185 - Ternary

Problem Description
source:https://uva.onlinejudge.org/external/111/11185.html

You will be given a decimal number. You will have to convert it to its ternary (Base 3) equivalent. Input The input file contains at most 100 lines of inputs. Each line contains a non-negative decimal integer N (N < 1000000001). 

Input 

is terminated by a line containing a negative value. This line should not be processed. 

Output 

For each line of input produce one line of output. This line contains the ternary equivalent of decimal value N. 

image

Solution of 11172 - Relational Operator

Problem Description
source:https://uva.onlinejudge.org/external/111/11172.html

Some operators checks about the relationship between two values and these operators are called relational operators. Given two numerical values your job is just to find out the relationship between them that is (i) First one is greater than the second (ii) First one is less than the second or (iii) First and second one is equal. 

Input 

First line of the input file is an integer t (t < 15) which denotes how many sets of inputs are there. Each of the next t lines contain two integers a and b (|a|, |b| < 1000000001). 

image

Algorithm of 11152 - Colourful Flowers

Problem Description Link
Algorithm:
This is a simple problem .However you can follow this technique .
In this problem if you just find the radius of inner circle of triangle and outer circle of triangle
 then you can calculate easily.  determine the both radius formula are
outer_circle_radius=(a*b*c)/(4*area_of_triangle);
inner_circle_radius=(area_of_triangle/s);
s=sqrt(s*(s-a)*(s-b)*(s-c));
image

Solution of 11152 - Colourful Flowers

Problem Description
source:https://uva.onlinejudge.org/external/111/11152.html

“Roses are red, violets are blue...” Millionaire Mr Smith is well-known — not for his wealth, but for his odd sense of “art”... Mr Smith has got a circular garden. On the boundary he picks three points and gets a triangle. He then finds the largest circle in that triangular region. So he gets something like this: Mr Smith then plants yellow sunflowers, blue violets and red roses in the way shown in the figure. (Nice combination, eh? :-) Given the lengths of the three sides of the triangle, you are to find the areas of the regions with each kind of flowers respectively.

Input 

Each line of input contains three integers a, b, c, the lengths of the three sides of the triangular region, with 0 < a ≤ b ≤ c ≤ 1000. 

Algorithm of 11150 - Cola

Problem Description Link
Algorithm:
This is a very simple problem just you need to read carefully .
The main condition for this problem is " A bottle of Choco Cola for every 3 empty bottles returned ".
Now you decide to buy some (say N) bottles of cola from the store. You would like to know how you can get the most cola from them.
However you can follow this method to solve this problem.

image

Solution of 11150 - Cola

Problem Description
source:https://uva.onlinejudge.org/external/111/11150.html

You see the following special offer by the convenience store:
      “A bottle of Choco Cola for every 3 empty bottles returned”
 Now you decide to buy some (say N) bottles of cola from the store. You would like to know how you can get the most cola from them. 
     The figure below shows the case where N = 8. Method 1 is the standard way: after finishing your 8 bottles of cola, you have 8 empty bottles. Take 6 of them and you get 2 new bottles of cola. Now after drinking them you have 4 empty bottles, so you take 3 of them to get yet another new cola. Finally, you have only 2 bottles in hand, so you cannot get new cola any more. Hence, you have enjoyed 8 + 2 + 1 = 11 bottles of cola. 
          You can actually do better! In Method 2, you first borrow an empty bottle from your friend (?! Or the storekeeper??), then you can enjoy 8 + 3 + 1 = 12 bottles of cola! Of course, you will have to return your remaining empty bottle back to your friend.