The question (RECIPE) is very easy. I have submitted this answer. The logic is also very simple. I am just finding the minimum number among all the numbers entered, and then dividing each of those entered numbers by this minimum number. If on remainder in all cases is zero, we have got our GCD. Else, I simply print all the numbers as given.

But for some strange reason, I am getting WA. Can someone help me?

Thanks!

I think you don’t understand gcd very well.

What if you have two numbers - *4* and *6*. Your programm claim, that **greatest common divisor** of these two numbers is *1*. But in fact it’s *2*. So for input:

```
1
2 4 6
```

You obtain output

```
4 6
```

but correct answer is

```
2 3
```

You should read some tutorial about Euclidian algorithm and finding gcd on wikipedia or here.

note on my code: the gcd block is taken from wiki url i have shown above. and main block is my c++ code. i initialised arr of 50 ingredients and saved ingredients in it. and then i have taken cmmn - the greatest common divisor for ingredients in the array. if cmmn==1 then the array has no gcd, so i just printed out the arr itself. if cmmn is equal to ingredients of arr then yes==1, which means that all ingredients in the arr are same numbers, for ex 4 as given in the codechef sample output, if so i printed out 1 for every ingredient of arr. and if there exist gcd(here cmmn) other than 1 and ingredints itself, then print out arr[i]/cmmn. that is it.

NOTE: i still have difficulty in understanding the binary gcd algo.