10176 - Ocean Deep ! - Make it shallow !!


Difficulty : easy

Solution Description :
Base conversion and modulus 

Compute (A[0]A[1]A[2]....A[n]) (base 2) modulo (R)10, denoted by (s)10 = (A[0]A[2]A[3]...A[n])2 mod (R)10

Simulate the modulo step by step using the following algorithm:

s = 0;
for (i=n; i>=0; i--) {
  s *= b; //here b=2
  s += A[i];
  s %= R;
}