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

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

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. 

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.