You are on page 1of 11

# Problem A

Goalkeepers
Input: Standard Input Output: Standard Output

When I was a high school student, we took the game of soccer very seriously. In our class team, there were two goalkeepers one of them being myself. Being the GR !" fellow that I am, you certainly know who was the better goalkeeper. But for some very strange and unfair reasons the other goalkeeper somehow always got to play the games. But one day fate intervened. #uring the first half of the game, our other goalkeeper conceded \$ goals% #uring the half time interval, our classmates got very furious and angrily shouted to the coach that he must change the goalkeeper at second half and give the world class keeper at his bench &"hat's me% (#) a go. *o, I played the second half as a substitute goalkeeper. "hen guess what. !s this is not a fairy tale, I put on an assured and accomplished display of goalkeeping and let in another \$ goals in our net. *o, that is \$ in the first half and \$ in the second half a total of +, goals conceded in the match. -ur opponent got very fond of both the keepers and started a campaign to play both of us in the following matches, one in the first half and the other in the second. .ow, you are given the number of goals conceded in the first half and in the second half of some matches, you'll have to tell me the total number of goals we conceded in the match, I am too embarrassed to count them after all. () Input "he +st line of input contains only an integer, T &"/0+11). ach of the following T lines contains 2 integers first and second the number of goals conceded in the first half and in the second half respectively. 3ou can assume that for all cases 0<=first, second <=100. Output 4or each test case, print a line in the format, 5 Case V: Y6, where V is the case number 7 Y is the total number of goals our team conceded in the match. Sample Input 2 2 2 7 7 Output for Sample Input Case 1: 4 Case 2: 14

NOT : "he following 8 9 8:: code can be used for this problem(
#include<stdio.h> int main() { int t,i,first,second,ans; scanf( !d ,"t); for(i # 1; i <# t; i\$\$)

{ scanf( !d!d ,"first,"second); %% %% %% %% &rite 'our code or formula here for e(am)le, if 'ou thin* ans # first minus second then &rite ans # first + second; (&ithout ,uotes)

## %% )rintin- the ans&er )rintf( Case !d: !d.n ,i,ans); / return 0; /

Problem B
Beautiful Flower
Input: Standard Input Output: Standard Output

! beautiful flower is floating on the lake which has its root in the soil under the water. "his scenario is shown in the picture given below(

*ometimes the flower moves to its right due to air flow and touches the water at point 8. We know the distance d &B8) and the distance ! &B ), which is the distance of the flower from water level when it is not affected by air i.e., !B 7 ! are perpendicular to B8. Given d and !, we need to find the depth of the lake. Input "he +st line of input contains only an integer, T &"/0+11). ach of the following T lines contains 2 integers ! and d. 3ou can safely assume that d is always greater than ! in any input case. Output 4or each test case, print a line in the format, 5 Case V: Y6, where V is the case number 7 Y is the depth of the lake. ;rint < digits after the decimal point. Sample Input 2 1 2 2 3 Output for Sample Input Case 1: 4.730000 Case 2: 3.230000

NOT : "he following 8 9 8:: code can be used for this problem(
#include<stdio.h> int main() { int t,i; dou5le (,d,ans; scanf( !d ,"t);

for(i # 1; i <# t; i\$\$) { scanf( !lf!lf ,"(,"d); %% %% %% %% %% %% %% %% &rite 'our code or formula here for e(am)le, if 'ou thin* ans # ( di6ided 5' d, &rite ans # (%d; (&ithout ,uotes) if 'ou thin* ans # ( (( multi)lied 5' d) + 2) di6ided 5' 4, &rite 7ans # ((8d + 2)%4;9 (&ithout ,uotes) &rite 'our code or formula here

/ return 0; /

## %% )rintin- the ans&er )rintf( Case !d: !.1lf.n ,i,ans);

Problem C
Emoogle Numbers
Input: Standard Input Output: Standard Output

We have a very famous and popular fellow in our problem setters' panel. He is so famous that his name is immaterial. Some of his admirers have recently given him the nickname 'Emoogle'. Let's stick to that name in our discussion for now. Being such a kind, friendly and generous person as he is, Emoogle is often known to give treats to the other problem setters. Some times, there is a strange rumor in the air that his treats are mostly due to the fact that, if he is not sparing enough for those treats, 'problems' will be created. But let's not pay heed to such nonsense! Now, in our gatherings, if the number of people present is divisible by 3 & 5 but not divisible by 4 then the smart Emoogle somehow manages a way to escape without giving a treat. So, we call the numbers that are divisible by 3 & 5 but not are not divisible by 4 to be Emoogle numbers. Given two integers, A & B, your task is to count the number of Emoogle numbers between A & B (inclusive) Input "he +st line of input contains only an integer, T &"/0+11). ach of the following T lines contains 2 integers " 7 # \$0<=",#<=10000%. 3ou can also assume that " <= #. Output 4or each test case, print a line in the format, 5 Case V: Y6, where V is the case number 7 Y is the number of moogle numbers between " 7 # inclusively. Sample Input 2 1 100 10 10 Output for Sample Input Case 1: 3 Case 2: 0

Problem D-E
Can ou !wap It """""
Input: Standard Input Output: Standard Output

&Note: T'is pro(lem 'as t)o *ersions. T'e easier *ersion 'as smaller input ran+e and t'is *ersion is ,ro(lem -. On t'e ot'er 'and, t'e same pro(lem onl. )it' a lar+er ran+e is treated as ,ro(lem . ,lease c'ec/ t'e Input specification section for more detail a(out t'e input ran+e for eac' pro(lem. 0 You are given a permutation of the numbers 1,2,3,.n (All the numbers from 1,2,3,.,n are given but not in any particular order). At any single move you can swap (exchange) any two neighboring elements. If two numbers are next to each other they are neighbors. What is the minimum of number of swaps needed to sort them in ascending order? Input The input contain multiple test cases. Each case starts with a line containing a positive integer n. Next line contains n space separated integers. All these integers are from 1 to n and they are distinct. The last case contains n where n=0. This case should not be processed. For the easy version (Problem D) 1<=n<=1000 For the hard version (Problem E) 1<=n<=100000 Output For every test case, on a single line output the minimum number of swap needed to make the list sorted in ascending order. Sample Input 4 1 4 2 4 4 2 1 0 Output for Sample Input 1 4

Output !planation: In the second test case first two elements are swapped. Now it becomes 2 3 1. Then last two elements are swapped, It becomes 2 1 3.Then finally first two elements are again swapped.So It becomes 1 2 3.

Problem F-G
Bitwise #ania
Input: Standard Input Output: Standard Output

&Note: T'is pro(lem 'as t)o *ersions. T'e easier *ersion 'as smaller input ran+e and t'is *ersion is ,ro(lem 1. On t'e ot'er 'and, t'e same pro(lem onl. )it' a lar+er ran+e is treated as ,ro(lem 2. ,lease c'ec/ t'e Input specification section for more detail a(out t'e input ran+e for eac' pro(lem. 0 ! (it)ise operation operates on one or more bit patterns at the level of their individual bits. Being learned about "N-, O3, 4O3 and NOT these four bitwise operators, your cryptography course advisor have given you some challenging task to convert a initially given =2 bit unsigned number& 5) to another =2 bit unsigned number&V) using a 6e. *alue. >nfortunately, he?s forgotten to tell you the 6e., so you have to use 5 as 6e.. .ow, at each conversion, you have four options to operate with the number( @ Bitwise "N- with 5 @ Bitwise O3 with 5 @ Bitwise 4O3 with 5 @ Bitwise NOT But, the fact is you must use all of these four bitwise operators at least one time and total bitwise operation must be minimum 7 times. "hat is, if you use total a time !.# operator, ( time -R operator, c time A-R operator and d time .-" operator, then these two conditions must suffice( 8 a, (, c, d all must be non9:ero 8 a ; ( ; c ; d <= 7 -bviously , you can use any operations in any order . *o, given 5, V, 7, you have to find out is it possible to convert 5 to V using minimum 7 bitwise conversion. If it possible, then find out minimum bitwise conversion & <= 7 % needed to convert 5 to V . Input "here will be at most +11\$ test cases in the input file. ach case contains = unsigned integer 5 \$0<=5<=>?= %, V \$0<=V<=>?= % and 7 \$7 <=@% in a line. 4or eas. version &,ro(lem 1%, 7 <=10 4or 'ard version, &,ro(lem 2% 7<=100000A "he end of input will be denoted by a case with 5 = 0,V = 0 , 7 = 0. "his case should not be processed.

Output 4or each test case, if it is possible to convert, then you have to print a line in the format, 5Case 4: Y6, where 4 is the case number 7 Y is minimum bitwise conversion & <= 7 % needed to convert 5 to V. -therwise , print BCase 4: 91C. Sample Input
0 0 4 24 43 7 17 4224217223 1 0 0 0

## Output for Sample Input

Case 1: 4 Case 2: +1 Case 4: 1

!planation of sample input: In the first sample, you can do the following conversion( 0 O3 0 =< 0 NOT 0 =< @=D@DEA=DF
@=D@DEA=DF "N- 0 =< 0 0 4O3 0 =< 0 *o, in , conversion using all the four bitwise operator 0 can be converted to 0 using key 0.

In the second sample, you can?t do the conversion from =? to @F using key =? anyhow you try. But in the t'ird sample you can do the following conversion( EA "N- EA =< EA EA 4O3 EA =< 0 0 O3 EA =< EA EA "N- EA =< EA NOT EA =< @=D@DEA==G @=D@DEA==G O3 EA =< @=D@DEA=DF
"otal E operations. 3ou may check out that you can do the same conversion in F or D operation, but as 7 is E, so you have to find minimum conversion greater than or eBual E. *o, output will be E.

Trut' ta(le for t'e (it)ise operations: " 1 1 + + # 1 + 1 + NOT " + + 1 1 " "N- # 1 1 1 + " O3 # 1 + + + " 4O3 # 1 + + 1

Problem \$-I
Birt%&a' Part'
Input: Standard Input Output: Standard Output

the position&+Ibased) of candy boD which is replaced, and the number of candies in the new boD. 4or Buestions of *ushi those two numbers&a and () will be the positions between which *ushi would like to search for option. ;ositions are +Ibased and will be between + and ., and you have to search inclusive i.e. both positions are also included in search. !nd you can safely assume that a /0 ( in second type. I 3ou have to take two different boDes. I .umber of candy in each boD at any time will be between + and +,111,111,111 &inclusive). I 4or every type 2 Buery, i.e. = a (, a <= (. I 1 <= 1 <= =0 4or easy version, \$,ro(lem H%, 1 <= T <= 10, 1 <= N <= 1000, 1 <= 7 <= F0 4or hard version, \$,ro(lem I%, 1 <= T <= ?, 1 <= N <= @0000, 1 <= 7 <= @0000 Output 4or each case, the output will start with a line BCase J<caseKno<:C in a single line without the Buotes&5) and caseJno representing the case number for that case starting with +. ach of the neDt output lines for that case is the Buestions asked by *ushi in Bueries &i.e. Bueries of type 2). 4or each Buestion that *ushi ask, output a number representing the number of options *ushi has. "he number will fit in a =2Ibit signed integer. Sample Input
1 3 10 10 1 2 104 4 3 100 1 4 4 22 2 2 2 2 1 3 2 1 2 2 1 4 1 3 1 2 2 2 1 4 3 2 1 3 1 : 1403002 2 1 10

## Output for Sample Input

Case #1: 3 2 0 2 1 2

Problem (-)
Pole an& *ire
Input: Standard Input Output: Standard Output

&Note: T'is pro(lem 'as t)o *ersions. T'e easier *ersion 'as smaller input ran+e and t'is *ersion is ,ro(lem L. On t'e ot'er 'and, t'e same pro(lem onl. )it' a lar+er ran+e is treated as ,ro(lem 6. ,lease c'ec/ t'e Input specification section for more detail a(out t'e input ran+e for eac' pro(lem. 0 "here are N poles along a road side. 3ou have to tie wires to the poles. 3ou can attach two ends of a wire to two different poles. ! pole might not have any wire attached to it. ! pole also must not have more than one wire attached to it. "wo wires must not cross each other but may overlap. 4or eDample, suppose there are G poles. *ay a wire is from pole + to pole , and another from pole 2 to pole G. "hese two wires crossed each other. *o such configuration is invalid. But say a wire is from pole + to pole , and another from pole 2 to pole =. "his is overlap, so it is valid configuration. Input 4irst line of the test file contains number of test cases, "&/0 =11). 4or every test case you will be given number of poles N, For the easy version (Problem J) 1<=N<=50 For the hard version (Problem K) 1<=N<=10^5 Output 4or every test case you are to output number of test case and number of ways of valid configuration. !s the number of ways is very big you have to output the result in modulo +11111=. Sample Input
2 4 4

## Output for Sample Input

Case 1: 4 Case 2: 2

Hint: 4or N = ?, there are , possible valid configurations. @ .o wires attached @ Wire from ;ole + to ;ole 2 @ Wire from ;ole 2 to ;ole = * Wire from Pole 1 to Pole 3