Why am I getting 10% wrong answer on this question?

judge
leds
online
problem
uri

#1

Question : https://www.urionlinejudge.com.br/judge/en/problems/view/1168
My solution : http://ideone.com/RW5deD
Gives correct answer on 90% cases. I don’t find any corner cases here.
Where am I going wrong?


#2

Bump.Anybody?


#3

why donot you use string in place of biginteger .


#4

But Biginteger never fails either,I’m just curious why is there this 10% fallacy in the code,but yeah I can consider using string too.