Solution of 10370 - Above Average

Problem Description
source:https://uva.onlinejudge.org/external/103/10370.html

It is said that 90% of frosh expect to be above average in their class. You are to provide a reality check.

Input 

The first line of standard input contains an integer C, the number of test cases. C data sets follow. Each data set begins with an integer, N, the number of people in the class (1 ≤ N ≤ 1000). N integers follow, separated by spaces or newlines, each giving the final grade (an integer between 0 and 100) of a student in the class. 

Soution of 10346 - Peter's Smokes

Problem Description
source:https://uva.onlinejudge.org/external/103/10346.html

Peter has n cigarettes. He smokes them one by one keeping all the butts. Out of k > 1 butts he can roll a new cigarette. 
         How many cigarettes can Peter have? 

Input 

Input is a sequence of lines. Each line contains two integer numbers giving the values of n and k. The input is terminated by end of file. 

Output 

For each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Peter can have. 

image

Solutio of 10340 - All in All

Problem Description
source:https://uva.onlinejudge.org/external/103/10340.html

You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted into the original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded in the final string. 
         Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s. 

Input 

The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF. 

image

Algorithm of 543 - Goldbach's Conjecture

Problem Description Link
Algorithm: 
To solve this problem you can follow this technique
1. At first you need to generate prime number  up to 1000000
    to generate prime number you can use sieve method . this method is faster than others.
image

Solution of 543 - Goldbach's Conjecture

Problem Description
source:https://uva.onlinejudge.org/external/5/543.html

In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture:
       Every number greater than 2 can be written as the sum of three prime numbers. 
       Goldbach was considering 1 as a primer number, a convention that is no longer followed. Later on, Euler re-expressed the conjecture as:
       Every even number greater than or equal to 4 can be expressed as the sum of two prime numbers.

For example: 

    • 8 = 3 + 5. Both 3 and 5 are odd prime numbers.
    • 20 = 3 + 17 = 7 + 13.
    • 42 = 5 + 37 = 11 + 31 = 13 + 29 = 19 + 23.

image

Algorithm of 10327 - Flip Sort

Problem Description Link
Algorithm: 
 For solution of this problem you can use Bubble sort or selection sort etc
when you starting the sort you need exchange data item
when exchange data then increase the value of (Flip)
finally after complete the sort you need print (Flip)
selection sort is the best for running time.
image

Solution of 10327 - Flip Sort

Problem Description
source:https://uva.onlinejudge.org/external/103/10327.html

Sorting in computer science is an important part. Almost every problem can be solved effeciently if sorted data are found. There are some excellent sorting algorithm which has already acheived the lower bound n · lg n. In this problem we will also discuss about a new sorting approach. In this approach only one operation (Flip) is available and that is you can exchange two adjacent terms. If you think a while, you will see that it is always possible to sort a set of numbers in this way. 
      A set of integers will be given. Now using the above approach we want to sort the numbers in ascending order. You have to find out the minimum number of flips required. Such as to sort ‘1 2 3’ we need no flip operation whether to sort ‘2 3 1’ we need at least 2 flip operations. 

image

Algorithm of 10300 - Ecological Premium

Problem Description Link
Algorithm:
This is a simple problem you can follow this technique.
Let t is test case n is the number of input each test case
and a, b, c are input for n times.
image

Solution of 10300 - Ecological Premium

Problem Description
source:https://uva.onlinejudge.org/external/103/10300.html

German farmers are given a premium depending on the conditions at their farmyard. Imagine the following simplified regulation: you know the size of each farmer’s farmyard in square meters and the number of animals living at it. We won’t make a difference between different animals, although this is far from reality. Moreover you have information about the degree the farmer uses environment-friendly equipment and practices, expressed in a single integer greater than zero. The amount of money a farmer receives can be calculated from these parameters as follows. First you need the space a single animal occupies at an average. This value (in square meters) is then multiplied by the parameter that stands for the farmer’s environment-friendliness, resulting in the premium a farmer is paid per animal he owns. To compute the final premium of a farmer just multiply this premium per animal with the number of animals the farmer owns.

image

Algorithm of 10242 - Fourth Point !!

Problem Description Link
Algorithm:

To solve this problem firstly you need to find the common   (x, y) coordinates,  then you find other two point .
After that you need find a,b
ie. common point (x2,y2) and other two point (x1,y1) and(x3,y3).
       a=(x1+x3)/2;
        b=(y1+y3)/2;
        x4=2*a-x2;
        y4=2*b-y2;
image