[Discussion ]Google Code Jam Started

[Discussion ]Google Code Jam Started

Minion hitman 1920x1200
Deal Subedar
1
19
1522
19

Anyone Participating in code jam can share thier problems and answer here lets qualify the round together. ~ Respect

9 Comments  |  
4 Dimers
Minion hitman 1920x1200
Deal Subedar
1
19
1522
19

First Problem 1:

Problem A. Counting Sheep
Confused? Read the quick-start guide.
Small input
points
You have solved this input set.
Large input
points
You have already tried this input set. (Judged at the end of the contest.)
Problem

Bleatrix Trotter the sheep has devised a strategy that helps her fall asleep faster. First, she picks a number N. Then she starts naming N, 2 × N, 3 × N, and so on. Whenever she names a number, she thinks about all of the digits in that number. She keeps track of which digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) she has seen at least once so far as part of any number she has named. Once she has seen each of the ten digits at least once, she will fall asleep.

Bleatrix must start with N and must always name (i + 1) × N directly after i × N. For example, suppose that Bleatrix picks N = 1692. She would count as follows:

N = 1692. Now she has seen the digits 1, 2, 6, and 9.
2N = 3384. Now she has seen the digits 1, 2, 3, 4, 6, 8, and 9.
3N = 5076. Now she has seen all ten digits, and falls asleep.
What is the last number that she will name before falling asleep? If she will count forever, print INSOMNIA instead.

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each consists of one line with a single integer N, the number Bleatrix has chosen.

Output

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the last number that Bleatrix will name before falling asleep, according to the rules described in the statement.

Limits
≤ T ≤ 100.
Small dataset
≤ N ≤ 200.
Large dataset
≤ N ≤ 106.
Sample

Input

Output
0
2
1692

Case #1: INSOMNIA
Case #2: 10
Case #3: 90
Case #4: 110
Case #5: 5076

In Case #1, since 2 × 0 = 0, 3 × 0 = 0, and so on, Bleatrix will never see any digit other than 0, and so she will count forever and never fall asleep. Poor sheep!

In Case #2, Bleatrix will name 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. The 0 will be the last digit needed, and so she will fall asleep after 10.

In Case #3, Bleatrix will name 2, 4, 6… and so on. She will not see the digit 9 in any number until 90, at which point she will fall asleep. By that point, she will have already seen the digits 0, 1, 2, 3, 4, 5, 6, 7, and 8, which will have appeared for the first time in the numbers 10, 10, 2, 30, 4, 50, 6, 70, and 8, respectively.

In Case #4, Bleatrix will name 11, 22, 33, 44, 55, 66, 77, 88, 99, 110 and then fall asleep.

Case #5 is the one described in the problem statement. Note that it would only show up in the Large dataset, and not in the Small dataset.

Missing
Deal Cadet
1
71
496
6

@hitmanranger i cannot think of any other approach except brute force. Do you have any better approach?

Minion hitman 1920x1200
Deal Subedar
1
19
1522
19
@makeourdeal wrote:

@hitmanranger i cannot think of any other approach except brute force. Do you have any better approach?


we can use hashing here . because brute force wont work.

Missing
Deal Cadet
1
71
496
6
@hitmanranger wrote:

@makeourdeal wrote:

@hitmanranger i cannot think of any other approach except brute force. Do you have any better approach?


we can use hashing here . because brute force wont work.


hashing for N, 2N, 3N?

283yu34yu5
Deal Lieutenant
18
0
6460
78

Isn’t this Online Mass Copying? https://cdn1.desidime.com/assets/textile-editor/icon_biggrin.gif

Download
Deal Subedar
2
132
1812
128

you can use set and keep adding digits to it
stop when length becomes 10

Download
Deal Subedar
2
132
1812
128

you can use set and keep adding digits to it
stop when length becomes 10

Missing
Deal Cadet
1
71
496
6
@ḾᾍJἘşṬίḉ wrote:

you can use set and keep adding digits to it
stop when length becomes 10


How will you know digits of k*N without actually calculating the number? Is there any pattern?

Minion hitman 1920x1200
Deal Subedar
1
19
1522
19
@ḾᾍJἘşṬίḉ wrote:

you can use set and keep adding digits to it
stop when length becomes 10


BRO YOU CAN USE HASH TABLE FUNCTION I JAVA AND RUN THE LLOPP TILL THE LENGTH THAT WILL SOLVE THE PROBLEM

Missing