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

Solution of 10242 - Fourth Point !!

Problem Description
source:https://uva.onlinejudge.org/external/102/10242.html

Given are the (x, y) coordinates of the endpoints of two adjacent sides of a parallelogram. Find the (x, y) coordinates of the fourth point. 

Input 

Each line of input contains eight floating point numbers: the (x, y) coordinates of one of the endpoints of the first side followed by the (x, y) coordinates of the other endpoint of the first side, followed by the (x, y) coordinates of one of the endpoints of the second side followed by the (x, y) coordinates of the other endpoint of the second side. All coordinates are in meters, to the nearest mm. All coordinates are between −10000 and +10000. Input is terminated by end of file. 

image

Solution of 10235 - Simply Emirp

Problem Description
source:https://uva.onlinejudge.org/external/102/10235.html

An integer greater than 1 is called a prime number if its only positive divisors (factors) are 1 and itself. Prime numbers have been studied over the years by a lot of mathematicians. Applications of prime numbers arise in Cryptography and Coding Theory among others. 
      Have you tried reversing a prime? For most primes, you get a composite (43 becomes 34). An Emirp (Prime spelt backwards) is a Prime that gives you a different Prime when its digits are reversed. For example, 17 is Emirp because 17 as well as 71 are Prime. 
     In this problem, you have to decide whether a number N is Non-prime or Prime or Emirp. Assume that 1 < N < 1000000. 
     Interestingly, Emirps are not new to NTU students. We have been boarding 199 and 179 buses for quite a long time! 

image

Algorithm of 10235 - Simply Emirp

Problem Description Link
Algorithm:
It is a simple problem but you must read carefully
this problem check three condition
    1. "N is not prime.", if N is not a Prime number.
image

Solution of 10195 - The Knights Of The Round Table

Problem Description
source:https://uva.onlinejudge.org/external/101/10195.html

King Arthur is planning to build the round table in a new room, but this time he wants a room that have sunlight entering it, so he planned to build a glass roof. He also wishes his round table to shine during the day, specially at noon, so he wants it to be covered totally by the sunlight. But Lancelot wants the glass part of the room roof to be triangular (and nobody knows the reason why, maybe he made a vow or something like that). So, there will be a triangular area in the room which will be all covered by the sunlight at noon and the round table must be build in this area. 
     Now, King Arthur wants to build the biggest table that he cans such that it fits in the triangular sunlighted area. As he is not very good in geometry, he asked Galahad to help him (Lancelot is very good in geometry, but King Arthur didn’t asked Lancelot to help him because he feared that he would come up with another strange suggestion). 
    Can you help Galahad (since he’s not too good with computers) and write a program which gives the radius of the biggest round table that fits in the sunlighted area? You can assume that the round table is a perfect circle. 

image

Algorithm of 10195 - The Knights Of The Round Table

Problem Description Link
Algorithm:

This is a simple problem you can solve this problem easily . Just follow this stapes
image

Algorithm of 10110 - Light, more light

Problem Description Link
Algorithm:
To solve this problem you need to know last bulb is on or off.
Every i'th walk, only bulbs which serial divisible by i will be toggled(means on to off or off to on).
image

Solution of 10110 - Light, more light

Problem Description
source:https://uva.onlinejudge.org/external/101/10110.html

There is man named ”mabu” for switching on-off light in our University. He switches on-off the lights in a corridor. Every bulb has its own toggle switch. That is, if it is pressed then the bulb turns on. Another press will turn it off. To save power consumption (or may be he is mad or something else) he does a peculiar thing. If in a corridor there is n bulbs, he walks along the corridor back and forth n times and in i-th walk he toggles only the switches whose serial is divisable by i. He does not press any switch when coming back to his initial position. A i-th walk is defined as going down the corridor (while doing the peculiar thing) and coming back again. Now you have to determine what is the final condition of the last bulb. Is it on or off?

image

Solution of 10107 - What is the Median

Problem Description
source:https://uva.onlinejudge.org/external/101/10107.html

Median plays an important role in the world of statistics. By definition, it is a value which divides an array into two equal parts. In this problem you are to determine the current median of some long integers. Suppose, we have five numbers {1,3,6,2,7}. In this case, 3 is the median as it has exactly two numbers on its each side. {1,2} and {6,7}. If there are even number of values like {1,3,6,2,7,8}, only one value cannot split this array into equal two parts, so we consider the average of the middle values {3,6}. Thus, the median will be (3+6)/2 = 4.5. In this problem, you have to print only the integer part, not the fractional. As a result, according to this problem, the median will be 4 !

Input 

The input file consists of series of integers X (0 ≤ X < 2 31) and total number of integers N is less than 10000. The numbers may have leading or trailing spaces. 

image

Algorithm of 10106 - Product

Problem Description Link
Algorithm:


To solve this problem you can use array and get input in string result is a int type array and a and b is char type array.
image

Solution of 10106 - Product

Problem Description
source:https://uva.onlinejudge.org/external/101/10106.html

The problem is to multiply two integers X, Y . (0 ≤ X, Y < 10250)

Input 

The input will consist of a set of pairs of lines. Each line in pair contains one multiplyer. 

Output 

For each input pair of lines the output line should consist one integer the product.

image

Algorithm of 10070 - Leap Year or Not Leap Year and

Problem Description Link
In this problem year length may 4 digit to 10000 digit so you need to handel big integer to solve this problem.
len = strlen (year);
        for (i=0; i< len; i++)
    mod4 = ((mod4 * 10) + (year[i]-'0')) % 4;

image

Solution of 10071 - Back to High School Physics

Problem Description
source:https://uva.onlinejudge.org/external/100/10071.html

A particle has initial velocity and acceleration. If its velocity after certain time is v then what will its displacement be in twice of that time? 

Input 

The input will contain two integers in each line. Each line makes one set of input. These two integers denote the value of v (−100 ≤ v ≤ 100) and t (0 ≤ t ≤ 200) (t means at the time the particle gains that velocity) 

image

Solution of 10070 - Leap Year or Not Leap Year and

Problem Description
source:https://uva.onlinejudge.org/external/100/10070.html

The ancient race of Gulamatu is very advanced in their year calculation scheme. They understand what leap year is (A year that is divisible by 4 and not divisible by 100 with the exception that years that are divisible by 400 are also leap year.) and they have also similar festival years. One is the Huluculu festival (happens on years divisible by 15) and the Bulukulu festival (Happens on years divisible by 55 provided that is also a leap year). Given an year you will have to state what properties these years have. If the year is not leap year nor festival year, then print the line ‘This is an ordinary year.’ The order of printing (if present) the properties is: leap year → huluculu → bulukulu. 

image

Algorithm of 136 - Ugly Numbers

Problem Description Link

 This problem can be solved following stapes:
1. Generate a list of ugly numbers bottom to up
 example:
image

Solution of 136 - Ugly Numbers

Problem Description
source:https://uva.onlinejudge.org/external/1/136.html

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 
          1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... 
shows the first 11 ugly numbers. By convention, 1 is included. 
         Write a program to find and print the 1500’th ugly number. 

Input 

There is no input to this program. 

image

Solution of 10055 - Hashmat the brave warrior

Problem Description
source:https://uva.onlinejudge.org/external/100/10055.html

Hashmat is a brave warrior who with his group of young soldiers moves from one place to another to fight against his opponents. Before Fighting he just calculates one thing, the difference between his soldier number and the opponent’s soldier number. From this difference he decides whether to fight or not. Hashmat’s soldier number is never greater than his opponent.

Input 

The input contains two numbers in every line. These two numbers in each line denotes the number soldiers in Hashmat’s army and his opponent’s army or vice versa. The input numbers are not greater than 232. Input is terminated by ‘End of File’. 

image

Solution of 10041 - Vito's Family

Problem Description
source:https://uva.onlinejudge.org/external/100/10041.html

The world-known gangster Vito Deadstone is moving to New York. He has a very big family there, all of them living in Lamafia Avenue. Since he will visit all his relatives very often, he is trying to find a house close to them. 
    Vito wants to minimize the total distance to all of them and has blackmailed you to write a program that solves his problem. 

Input 

The input consists of several test cases. The first line contains the number of test cases. 
      For each test case you will be given the integer number of relatives r (0 < r < 500) and the street numbers (also integers) s1, s2, . . . , si , . . . , sr where they live (0 < si < 30000 ). Note that several relatives could live in the same street number. 

image

Algorithm of 10041 - Vito's Family

Problem Description Link


This problem you can solve easily .follow this stapes
           1.       Sort the input array of street number.
           2.       Determine the median of array.
               If no. of street is even then mid value are two . so  median is avg of two mid value. If                            no. of   street is odd then mid value is one . so median is that mid value.
                  i.e. 2 6 4 8 9 so median=4; and 2 4 6 8 7 3 so median=(6+8)/2;
image

Solution of 10035 - Primary Arithmetic

Problem Description
source:https://uva.onlinejudge.org/external/100/10035.html

Children are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the “carry” operation - in which a 1 is carried from one digit position to be added to the next - to be a significant challenge. Your job is to count the number of carry operations for each of a set of addition problems so that educators may assess their difficulty.

Input 

Each line of input contains two unsigned integers less than 10 digits. The last line of input contains ‘0 0’. 

image

Solution of 10038 - Jolly Jumpers

Problem Description
source:https://uva.onlinejudge.org/external/100/10038.html

A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n − 1. For instance, 
                1 4 2 3 
is a jolly jumper, because the absolutes differences are 3, 2, and 1 respectively. The definition implies that any sequence of a single integer is a jolly jumper. You are to write a program to determine whether or not each of a number of sequences is a jolly jumper. 

image

Solution of 10018 - Reverse and Add

Problem Description
source:https://uva.onlinejudge.org/external/100/10018.html

The “reverse and add” method is simple: choose a number, reverse its digits and add it to the original. If the sum is not a palindrome (which means, it is not the same number from left to right and right to left), repeat this procedure.

For example: 
                       195 Initial number 
                       591 
                       —– 
                       786 
                       687 
                      —– 
                     1473 
                     3741 
                     —– 
                    5214 
                    4125 
                    —– 
                    9339   Resulting palindrome

image

Solution of 1230 - MODEX

Problem Description
source:https://uva.onlinejudge.org/external/12/1230.html

Many well-known cryptographic operations require modular exponentiation. That is, given integers x, y and n, compute xy mod n. In this question, you are tasked to program an efficient way to execute this calculation.

Input 

The input consists of a line containing the number c of datasets, followed by c datasets, followed by a line containing the number ‘0’. Each dataset consists of a single line containing three positive integers, x, y, and n, separated by blanks. You can assume that 1 < x, n < 215 = 32768, and 0 < y < 231 = 2147483648

image

Solution of 1225 - Digit Counting

Problem Description
source:https://uva.onlinejudge.org/external/12/1225.html

Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N (1 < N < 10000). After that, he counts the number of times each digit (0 to 9) appears in the sequence. For example, with N = 13, the sequence is: 
                     12345678910111213
 In this sequence, 0 appears once, 1 appears 6 times, 2 appears 2 times, 3 appears 3 times, and each digit from 4 to 9 appears once. After playing for a while, Trung gets bored again. He now wants to write a program to do this for him. Your task is to help him with writing this program. 

image

Solution of 1124 - Celebrity jeopardy

Problem Description
source:https://uva.onlinejudge.org/external/11/1124.html

It’s hard to construct a problem that’s so easy that everyone will get it, yet still difficult enough to be worthy of some respect. Usually, we err on one side or the other. How simple can a problem really be? Here, as in Celebrity Jepoardy, questions and answers are a bit confused, and, because the participants are celebrities, there’s a real need to make the challenges simple. Your program needs to prepare a question to be solved — an equation to be solved — given the answer. Specifically, you have to write a program which finds the simplest possible equation to be solved given the answer, considering all possible equations using the standard mathematical symbols in the usual manner. In this context, simplest can be defined unambiguously several different ways leading to the same path of resolution. For now, find the equation whose transformation into the desired answer requires the least effort. For example, given the answer X = 2, you might create the equation 9 − X = 7. Alternately, you could build the system X > 0; X2 = 4. These may not be the simplest possible equations. Solving these mind-scratchers might be hard for a celebrity.

image

Algorithm of 913 - Joana and the Odd Numbers

Problem Description Link

To solve  this problem you need short-curt method other wise you get time limit exit
ie.
1
 3  5  7
 9 11 13 15 17
19 21 23 25 27 29 31
...
image

Solution of 913 - Joana and the Odd Numbers

Problem Description
source:https://uva.onlinejudge.org/external/9/913.html

Joana loves playing with odd numbers. In the other day, she started writing, in each line, an odd number of odd numbers. It looked as follows:


3 5 7 
9 11 13 15 17 
19 21 23 25 27 29 31
......