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

Solution of 11407 - Squares

Problem Description
source: http://uva.onlinejudge.org/external/114/11407.html

For any positive integer N, N = a 2 1 + a 2 2 + . . . + a 2 n that is, any positive integer can be represented as sum of squares of other numbers. Your task is to print the smallest ‘n’ such that N = a 2 1 + a 2 2 + . . . + a 2 n.

Input

The first line of the input will contain an integer ‘t’ which indicates the number of test cases to follow. Each test case will contain a single integer ‘N’ (1 ≤ N ≤ 10000) on a line by itself. 

image

Solution of 11498 - Division of Nlogonia

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

After centuries of hostilities and skirmishes between the four nations living in the land generally known as Nlogonia, and years of negotiations involving diplomats, politicians and the armed forces of all interested parties, with mediation by UN, NATO, G7 and SBC, it was at last agreed by all the way to end the dispute, dividing the land into four independent territories. 
           It was agreed that one point, called division point, with coordinates established in the negotiations, would define the country division, in the following way. Two lines, both containing the division point, one in the North-South direction and one in the East-West direction, would be drawn on the map, dividing the land into four new countries. Starting from the Western-most, Northern-most quadrant, in clockwise direction, the new countries will be called Northwestern Nlogonia, Northeastern Nlogonia, Southeastern Nlogonia and Southwestern Nlogonia. 

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

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

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

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*/

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.