Coffee Room

Discuss anything here - everything that you wish to discuss with fellow engineers.

12829 Members

Join this group to post and comment.

# Google code jam problem 1

Guys this is the first problem that was asked in google code jam for qualification

Why not we discuss these problems on ce so that it will help a lot of ceans to prepare for next year

So let us start

The

When a

In hopes of destroying the universe by means of a singularity, I have purchased

Initially, all the

I keep doing this for hours. Will the light be

The first line of the input gives the number of test cases,

For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is either "ON" or "OFF", indicating the state of the light bulb.

1 ≤

1 ≤

0 ≤

1 ≤

0 ≤

Why not we discuss these problems on ce so that it will help a lot of ceans to prepare for next year

So let us start

The

*Snapper*is a clever little device that, on one side, plugs its input plug into an output socket, and, on the other side, exposes an output socket for plugging in a light or other device.When a

*Snapper*is in the ON state and is receiving power from its input plug, then the device connected to its output socket is receiving power as well. When you snap your fingers -- making a clicking sound -- any*Snapper*receiving power at the time of the snap toggles between the ON and OFF states.In hopes of destroying the universe by means of a singularity, I have purchased

**N***Snapper*devices and chained them together by plugging the first one into a power socket, the second one into the first one, and so on. The light is plugged into the**N**th*Snapper*.Initially, all the

*Snapper*s are in the OFF state, so only the first one is receiving power from the socket, and the light is off. I snap my fingers once, which toggles the first*Snapper*into the ON state and gives power to the second one. I snap my fingers again, which toggles both*Snapper*s and then promptly cuts power off from the second one, leaving it in the ON state, but with no power. I snap my fingers the third time, which toggles the first*Snapper*again and gives power to the second one. Now both*Snapper*s are in the ON state, and if my light is plugged into the second*Snapper*it will be*on*.I keep doing this for hours. Will the light be

*on*or*off*after I have snapped my fingers**K**times? The light is*on*if and only if it's receiving power from the*Snapper*it's plugged into.**Input**The first line of the input gives the number of test cases,

**T**.**T**lines follow. Each one contains two integers,**N**and**K**.**Output**For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is either "ON" or "OFF", indicating the state of the light bulb.

**Limits**1 ≤

**T**≤ 10,000.**Small dataset**1 ≤

**N**≤ 10;0 ≤

**K**≤ 100;**Large dataset**1 ≤

**N**≤ 30;0 ≤

**K**≤ 108;
According to me the relation between n and k should be like this

l=n*2 if((k+1)%l==0) cout<