TCS Company Programming Technical

Grandpa's Candy Distribution

Rahul is considered to be the luckiest kid around, by his classmates - his grandpa has a candy factory! And the factory produces a thousand different flavours of candies!

Rahul's birthday is around the corner and the entire school is excited to receive the candies. Rahul approaches his grandpa and asks for candies to be distributed on his birthday.

His grandpa tasks him with a problem - he says that he will give him as many candies as he wants (N) of all distinct flavours for as many students in his school (K) if he can tell him the sum of the following:

The number of ways there are to choose K/2 candies out of N/2 disregarding the order of selection, and
The number of ways there are to choose K/2 candies out of N/2 taking into account the order of selection.


Give the answer, modulo 1000000007. Assume integer division while halving N and K.

Input Format:

First line contains a positive integer T determining the number of test cases
Next T lines contain two positive integers each, viz. N and K separated by white space.

Output Format:

For each test case, print a single integer per line denoting the sum of total number of ways to distribute N candies among K students as per grandpa's method, modulo 1000000007

Constraints:

1 <=T <= 1,000,000

2 <=N <=2000

2 <=K <=1000

Read Solution (Total 1)

TCS Other Question

Rotation

A Game developer is developing a game. To enrich his graphics he needs a quick API to do rotation and scaling of objects of various shapes that appear in the game. You have been chosen to partner this developer. Shoulder the responsibility of developing this API.

You have your work cut-out in form of the input and output specs below.

Input Format:

First line contains number of sides of a polygon, denoted by N
Next N lines contain x and y coordinates, respectively, of the points forming the polygon, delimited by space
Next line contains angle of rotation A
Next line contains scaling factor S
Last line contains coordinates about which the polygon has to be rotated, denoted by (a, b)

Output Format:

Print new coordinates of polygon after rotation and scaling

Constraints:

Polygon will be 3-sided or higher

x and y can be positive or negative integers or zero

Angle of rotation (A) can have only three discrete values {90, 180, 270} in degree

Positive angles indicate clock-wise rotation. Negative angles indicate anti clock-wise rotation

Scaling Factor S can be greater than 1

Point around which the polygon has to be rotated, denoted by (a, b) can be positive or negative integers or zero
A spherical solid ball of radius 58 mm is to be divided into eight equal parts by cutting it four times longitudinally along the same axis.Find the surface area of each of the final pieces thus obtained( in mm^2) ? (where pi= 22/7)
(a) 3365pi (b) 5046pi (c)1682pi (d) 3346pi