GCDPRF....My code is showing WA

Can anyone plz explain why is it happening?
Here’s the solution
https://www.codechef.com/viewsolution/53981058

You are breaking during the input. You should take the input first and then check the conditions.
Eg test -

2
2
6 7
1
4

1 Like

Thanks for the reply.
Are u saying that because my code is taking some time between two inputs that’s why its giving WA?

no you are not taking complete input of give test case.

2
3
6 7 8
1
4

for this test case after 7 you are breaking the loop so 8 is taken as n for next input

1 Like

Ohh…right i got it Thanks !!