Algorithm of 11479 - Is this the easiest problem

Problem Description Link
Algorithm:

This is a geometric problem . you  can solve this problem easily . you can follow this stapes
       1.       At first you need three value for three sides (ie. a, b, c)
          N.B.: three sides can formed a triangle if and only if third side is greater than summation of  
             other two side   . where third side is largest value among three sides value .
             (i.e.:  5, 9, 6 where third side is 9).
 2.            if possible formed a triangle then you need to check
                ·  Equilateral  - All three sides of valid triangle are equal
·  Isosceles  - Exactly two of the sides of a valid triangle are equal.
image

Solution of 11479 - Is this the easiest problem

Problem Description
source:https://uva.onlinejudge.org/external/114/11479.html

A triangle is a geometric shape with three positive sides. However, any given three sides won’t necessarily form a triangle. The three sides must form a closed region. Triangles are categorized depending on the values of the sides of a valid triangle. In this problem you are required to determine the type of a triangle. 

Input 

The first line of input will contain a positive integer T < 20, where T denotes the number of test cases. Each of the next T lines will contain three 32 bit signed integer. 

image

Algorithm of 11462 - Age Sort

Problem Description link
Algorithm:
This problem is easy just read carefully . In this problem need only sort the value and print sorted  value.
but if you solve it by iterative way then may you can get Time Limit Exit .
So you need to use any faster sort algorithm also you can use priority queue to solve this problem easily .
image

Solution of 11462 - Age Sort

Problem Description
source:https://uva.onlinejudge.org/external/114/11462.html

You are given the ages (in years) of all people of a country with at least 1 year of age. You know that no individual in that country lives for 100 or more years. Now, you are given a very simple task of sorting all the ages in ascending order. 

Input 

There are multiple test cases in the input file. Each case starts with an integer n (0 < n ≤ 2000000), the total number of people. In the next line, there are n integers indicating the ages. Input is terminated with a case where n = 0. This case should not be processed. 

image

Algorithm of 11455 - Behold my quadrangle

Problem Description Link
Algorithm:
This is a simple problem just follow this technique
1. if four side are equal then it is called "square".
2. if any tow pair side are equal then it is called "rectangle"
3. if each side is smaller or equal sum of other three side then it is called "quadrangle".
4. otherwise "banana"

example.
 10 8 7 6 is a quadrangle because
      1. 10<=(8+7+6)
    2. 8<=(10+7+6)
    3. 7<=(10+8+6)
    4. 6<=(10+8+7)
 1 1 9 9 is rectangle because two pair are equal
    1.  1 == 1
    2.  9 == 9
image

Solution of 11455 - Behold my quadrangle

Problem Description
source: https://uva.onlinejudge.org/external/114/11455.html

Any square is a rectangle, any rectangle is a quadrangle, and any quadrangle is composed of four sides. But not all rectangles are squares, not all quadrangles are rectangles, and not all sets of four sides are quadrangles. We have the length of four sides. You have to determine if they can form a square. If not, determine if they can form a rectangle. If not, determine if they can form a quadrangle. 

Input 

The first line of the input contains an integer indicating the number of test cases. For each test case, there is a line with four positive integer numbers, between 0 and 230

image

Algorithm of 11428 - Cubes

Problem Description Link
Algorithm:

Given a positive integer N you will have to find two positive integers x and y such that:


This is a simple problem. You can just follow this technique
for this problem solution you need two loop
first loop(i) start from cubic root of N  and to sqrt of N
second loop(j) start from 1 to i
and check (i*i*i)-(j*j*j) =N or not
if equal then print i and j

Solution of 11428 - Cubes

Problem Descriptio
source:https://uva.onlinejudge.org/external/114/11428.html

Given a positive integer N you will have to find two positive integers x and y such that:
                                                               N = x3 − y3

Input 

The input file contains at most 100 lines of inputs. Each line contains a positive integer N (0 < N ≤ 10000). Input is terminated by a line containing a single zero. This line should not be processed. 
image

Solution of 11417 - GCD

Problem Description
source:https://uva.onlinejudge.org/external/114/11417.html

Given the value of N, you will have to find the value of G. The definition of G is given below:

Here GCD(i, j) means the greatest common divisor of integer i and integer j. For those who have trouble understanding summation notation, the meaning of G is given in the following code: 



G=0;
for(i=1;i<N;i++)
for(j=i+1;j<=N;j++)
{
G+=GCD(i,j);
}
/*Here GCD() is a function that finds
the greatest common divisor of the two
input numbers*/

Algorithm of 11401 - counter

Problem Description Link
Algorithm:
You are given n rods of length 1, 2…, n. You have to pick any 3 of them & build a triangle. How many distinct triangles can you make? Note that, two triangles will be considered different if they have at least 1 pair of arms with different length.
To solve this problem you can follow this technique.
if we have a triangle with sides a,b,c therefore this must be true a+b>c , a+c>b , b+c>a

if n = 3
 we have 3 sticks
 1 2 3
image

Solution of 11401 - counter

Problem Description
source:https://uva.onlinejudge.org/external/114/11401.html

You are given n rods of length 1, 2, . . . , n. You have to pick any 3 of them and build a triangle. How many distinct triangles can you make? Note that, two triangles will be considered different if they have at least 1 pair of arms with different length.

Algorithm of 11389 - The Bus Driver Problem

Problem Description Link
Algorithm:
This is a simple problem . The problem say that
In a city there are n bus drivers. Also there are n morning bus routes & n afternoon bus routes with various lengths. Each driver is

assigned one morning route & one evening route. For any driver, if his total route length for a day exceeds d, he has to be paid

overtime for every hour after the first d hours at a flat r taka / hour. Your task is to assign one morning route & one evening route

to each bus driver so that the total overtime amount that the authority has to pay is minimized.
How ever you can follow this to solve the problem
image

Solution of 11389 - The Bus Driver Problem

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

In a city there are n bus drivers. Also there are n morning bus routes and n afternoon bus routes with various lengths. Each driver is assigned one morning route and one evening route. For any driver, if his total route length for a day exceeds d, he has to be paid overtime for every hour after the first d hours at a flat r taka / hour. Your task is to assign one morning route and one evening route to each bus driver so that the total overtime amount that the authority has to pay is minimized. 

Input 

The first line of each test case has three integers n, d and r, as described above. In the second line, there are n space separated integers which are the lengths of the morning routes given in meters. Similarly the third line has n space separated integers denoting the evening route lengths. The lengths are positive integers less than or equal to 10000. The end of input is denoted by a case with three 0’s. 

image

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.