You are on page 1of 6

NOTE: GO THROUGH RULES AND SPECIFICATIONS FILE BEFORE ANSWERING THE QUESTIONS

Problem1: Imagine you are teaching your younger brother how to find sine of an angle/number, he finds your teaching extremely boring and gets irritated. So you try to grab his attention with some of your coding skills. First you take a sequence of integers A0, A1,. AN-1. Initially Ai=i for all i. You need to perform some strange queries with it. Each query has the form "L R D" where 0 <= L <= R < N and D is an integer. If D=0 then you need to find the sum of sines of the numbers AL, AL+1, ..., AR that is sin AL + ... + sin AR. Otherwise you need to add D to the numbers AL, AL+1, ..., AR INPUT The first line contains two positive integers N and Q. Here, N <= 109 is the length of the initial sequence and Q <= 100000 is the number of queries you need to perform with it. The next Q lines describe queries, one per line. The i'th such line contains three integers L, R and D. Here 0 <= L <= R < N and-10000 <= D <= 10000. Output The output consists of answers for all queries where D=0. For each such query you must produce a line with the corresponding sines sum. Example Input: 56 040 021 342 040 2 3 -1 140 Output: 1.1350859 0.65354865 0.782376860

Problem2: Sam wants to build a hut for himself on a extremely rocky piece of land. For this he has 3 poles, since the ground is rocky he can place the poles only in some special places. So he has decided to build the hut in a triangular shape, with vertices in distinguished points and obviously he wants to maximize the area of the hut as you are his friend he comes to you for help!!! Write a program which: Input Each test case starts with an integer n (n 106). In each of the next n lines there is pair of integers separated by spaces, xi, yi, which are the coordinates for i-th point where a pole can potentially be located (0 xi,yi 10000). Output For each test case output a single integer - the area of the field surrounded by the fence, multiplied by 2. Example Input 5 00 10 01 12 11 Output 2 reads from the input the coordinates of the points which can hold the poles, calculates the maximal possible area of the hut.

Problem3: A new acting school was established by Ramesh. He wanted to promote the school by distributing invitation cards. He got printed invitation cards with all the necessary information . A lot of students were hired to distribute these invitations among the people. Each student volunteer has assigned exactly one metro stop and he or she stays there the whole day and gives invitation to people travelling by train The transport system there is: all lines are unidirectional and connect exactly two stops. Trains leave the originating stop with passengers each half an hour. After reaching the destination stop they return empty to the originating stop, where they wait until the next full half an hour, e.g. X:00 or X:30, where X denotes the hour. The fee for transport between two stops is given by special tables and is payable on the spot. The lines are planned in such a way, that each round trip (i.e. a journey starting and finishing at the same stop) passes through a Stop where each passenger has to pass a thorough check including body scan. All the student members leave the Stop each morning. Each volunteer is to move to one predetermined stop to invite passengers. There are as many volunteers as stops. At the end of the day, all students travel back to Stop. You are to write a computer program that helps Ramesh to minimize the amount of money to pay every day for the transport of their employees.

Input The input consists of N cases. The first line of the input contains only positive integer N. Then follow the cases. Each case begins with a line containing exactly two integers P and Q, 1 <= P,Q <= 1000000. P is the number of stops including CCS and Q the number of bus lines. Then there are Q lines, each describing one bus line. Each of the lines contains exactly three numbers - the originating stop, the destination stop and the price. The CCS is designated by number 1. Prices are positive integers the sum of which is smaller than 1000000000. You can also assume it is always possible to get from any stop to any other stop. Output For each case, print one line containing the minimum amount of money to be paid each day by ACM for the travel costs of its volunteers. Example Sample input: 2 22 1 2 13

1 2 1 33 46 1 2 10 2 1 60 1 3 20 3 4 10 245 4 1 50 Sample output: 46 210 Warning: large Input/Output data, be careful with certain languages Added by: Adrian Kosowski Date: 2004-06-06 Time limit: 5s Source limit:50000B Languages: All Resource: ACM Central European Programming Contest, Prague 1998 2

Problem4: After spending a long spell in the darkness, Lord Voldermort has returned from the dead. Now he seeks to take revenge on harry potter!! He resurrects all of his minions and captures harry to imprison him in an infinitely large room with an infinitely large chessboard. But this room is under Voldermorts spell which restricts the movement of harry on the chessboard. Moves possible for Harry are described by two pairs of integers: (a,b) and (c,d) From square (x,y) Potter can move to one of the squares: (x+a,y+b), (x-a,y-b), (x+c,y+d), (x-c,y-d). The start point is (0,0). Harry uses his awesome powers and finds out that if he reaches a square which is nearest* to the start point he can escape from this room. He can roam around the room as much as he wants (obeying the conditions above) but in the end he has to reach a square which is nearest* to his start point (excluding the start point (0,0) ). i.e. We want to know for which square different from (0,0) to which Harry can jump from start point (possibly in many moves) the distance** from start point is minimum. *Nearest point implies the point whose distance** from start point is minimum. **Distance of point (x,y) from start point is |x|+|y| Task Write a program which reads from standard input two pairs (a,b) and (c,d) of integers, different from (0,0), describing moves of Harry, determines a pair of integers (x,y) different from (0,0), for which Potter can jump (possibly in many moves) from square (0,0) to square (x,y) and for which the value |x|+|y| is the lowest. writes out to standard output the value |x|+|y|. Input Ten test cases. Each test consists of four numbers a,b,c,d in one line, separated by spaces. -100000 <= a, b, c, d <= 100000 Output For every test case your program should write a single line with a number equal the lowest possible value |x|+|y|. Test Case Input:

13 4 17 5 Output:2

Problem5: You are sitting in your mathematics class.Your teacher expects you to find all possible sextuples that satisfy:

Being lazy you want your computer to find out all sextuples You are given a set S of integers between -30000 and 30000 (inclusive) Input The first line contains integer N (1 N 100), the size of a set S. Elements of S are given in the next N lines, one integer per line. Given numbers will be distinct. Output Output the total number of plausible sextuples. Examples Input: 1 1 Output: 1 Input: 2 2 3 Output: 4 Input: 2 -1 1 Output: 24 Input: 3 5 7 10 Output: 10

You might also like