Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1

Ratings: (0)|Views: 171 |Likes:

### Availability:

See more
See less

11/15/2012

pdf

text

original

Basic Division
Problem 1: Prime Palindromes,
(K Narayan Kumar, CMI)
An integer is said to be a palindrome if it is equal to its reverse. For example, 79197 and 324423are palindromes. In this task you will be given an integer N, 1 ≤ N ≤ 1000000. You must find thesmallest integer M ≥ N such that M is a prime number and M is a palindrome.For example, if N is 31 then the answer is 101.
Input format
A single integer N, (1 ≤ N ≤ 1000000), on a single line.
Output format
Your output must consist of a single integer, the smallest prime palindrome greater than or equalto N.
Example
We now illustrate the input and output formats using the example described above.
Sample input:
31
Sample output:
101
Basic Division
(K Narayan Kumar, CMI)
The game of billiards involves two players knocking 3 balls around on a green baize table. Well,there is more to it, but for our purposes this is sufficient.The game consists of several rounds and in each round both players obtain a score, based on howwell they played. Once all the rounds have been played, the total score of each player isdetermined by adding up the scores in all the rounds and the player with the higher total score isdeclared the winner.The Siruseri Sports Club organises an annual billiards game where the top two players of Siruseri play against each other. The Manager of Siruseri Sports Club decided to add his owntwist to the game by changing the rules for determining the winner. In his version, at the end of each round the leader and her current lead are calculated. Once all the rounds are over the player who had the maximum lead at the end of any round in the game is declared the winner.Consider the following score sheet for a game with 5 rounds:
Round Player 1 Player 21 140 822 89 134

3 90 1104 112 1065 88 90
The total scores of both players, the leader and the lead after each round for this game is given below:
Round Player 1 Player 2 Leader Lead1 140 82 Player 1 582 229 216 Player 1 133 319 326 Player 2 74 431 432 Player 2 15 519 522 Player 2 3
The winner of this game is Player 1 as he had the maximum lead (58 at the end of round 1)during the game.Your task is to help the Manager find the winner and the winning lead. You may assume that thescores will be such that there will always be a single winner. That is, there are no ties.
Input format
The first line of the input will contain a single integer N (N ≤ 10000) indicating the number of rounds in the game. Lines 2,3,...,N+1 describe the scores of the two players in the N rounds. Linei+1 contains two integer Si and Ti, the scores of the Player 1 and 2 respectively, in round i. Youmay assume that 1 ≤ Si ≤ 1000 and 1 ≤ Ti ≤ 1000.
Output format
Your output must consist of a single line containing two integers W and L, where W is 1 or 2 andindicates the winner and L is the maximum lead attained by the winner.
Test Data
The range of values over which your program is to be tested is mentioned above. In addition,50% of the test cases will also satisfy N ≤ 1000.
Example
We now illustrate the input and output formats using the example described above.
Sample input:
5140 8289 13490 110

112 10688 90
Sample output:
1 58
Basic Division
Problem 1: BCCS Elections,
(K Narayan Kumar, CMI)
The Board of Cricket Control of Siruseri holds an election every year to elect a 3 member executive committee to run the affairs of the board. The executive committee is quite powerful,as it decides which television company gets to broadcast the Siruseri Cricket League and so on.The procedure for this election is the following. All those interested in serving as executivecommittee members inform the Manager. The Manager informs all the members of the BCCSabout the list of candidates. On the day of the election, each member of BCCS is allowed to votefor exactly one of the candidates. Finally all the votes are counted and the top three candidatesare deemed elected.Suppose there are 5 candidates
{1,2,3,4,5}
, 10 members in all in BCCS and the votes cast are asfollows:
Voter Vote1 22 53 44 45 36 17 28 19 110 2
Then, candidates 1, 2 (with 3 votes each) and 4 (with 2 votes) are elected to the executivecommittee.You are given the number of candidates and voters and the list of votes. Your task to determinethe candidate finishing third. You may assume that the votes are cast in such a way that there isnever a tie between the second and third best candidates or between the third and fourth bestcandidates.