1. 
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
* Angewandte Mathematik, SS11
* Problem: 10176 - Ocean Deep ! - Make it shallow !!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1117
*
* @author Unverzart Michael
* @author Wurth Manuel
* @version 1.0, 11/4/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.200
*/

public class Main {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String inputLine;
while((inputLine = reader.readLine())!=null)
{
if(inputLine.trim().length()>=2 && inputLine.endsWith("#")) {
long erg = 0;
for (char c : inputLine.toCharArray()) {
long dec = c-'0';
if(dec == 0 || dec == 1){
dec=2*erg+dec;
erg=dec%131071;
}
}
if(erg == 0) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}

}

2.

import java.io.*;

/**
* FWP, Angewandte Mathematik, SS11
* Problem: 10176 - Ocean Deep! - Make it shallow!!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1117
*
* @author Sebastian Stumpf
* @author Benjamin Vogt
* @version 1.0, 2011-04-20 13:21:51
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.184
*/

//my best Runtime
public class Main
{
// 500000 is enough, checked by trying
static char[] bitArr = new char[500000];
public static void main(String args[]) throws Exception
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
// read all chars of input in my char[] important: starts at 0, linear saving, ends at end
input.read(bitArr);
int result = 0;
// iterate through all emelents of bitArr
for(int bit: bitArr)
{
// compute modular result
if(bit == '0' || bit == '1')
result = ( ( ( result << 1 ) % 131071 ) + ( bit - '0' ) ) % 131071;
// interesting: both programs have accepted
// this one: input # --> output Yes
// my other version: input # -> no output
else if(bit == '#')
{
// output and resetting result if # is read
System.out.println(result == 0? "YES": "NO");
result = 0;
}
}
}
}

OTHER VERSIONS:
/**
* FWP, Angewandte Mathematik, SS11
* Problem: 10176 - Ocean Deep! - Make it shallow!!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1117
*
* @author Sebastian Stumpf
* @author Benjamin Vogt
* @version 1.0, 2011-04-20 11:26:59 // 2011-04-20 11:58:23
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: BigInt version: 0.644 // int version: 0.400
*/

import java.io.*;
import java.math.*;

public class Main2OtherVersions
{
static final int IPRIME = 131071;
static final BigInteger PRIME = BigInteger.valueOf(IPRIME);


static BigInteger createFromBinary(String s)
{
BigInteger result = BigInteger.ZERO;
for(int i = 0; i < s.length(); i++)
result = (result.shiftLeft(1)).add(BigInteger.valueOf(s.charAt(i) - '0'));
return result;
}

static int modOfBinary(String s, int n)
{
// (a+b) % m = ((a % m) + (b % m)) % m
// (a*b) % m = ((a % m) * (b % m)) % m
// Binary can be computed by 2 ways:
// 1. from the end to the front: 11101 = 1*2^0 + 0*2^1 + 1*2^2 + 1*2^3 + 1*2^4 = 29
// 2. from the fornt to the end: 11101 = (((((0 + 1)*2) + 1)*2 + 1)*2 + 0)*2 + 1 = 29
// We will use the second way, because that is perfectly for implementing in a loop and
// we have only one multiplication with 2 per runthrough.
// The second advantage is that the modular operation can be easily performed on that way.
int result = 0;
for(int i = 0; i < s.length(); ++i)
result = ( ( ( result << 1 ) % n ) + ( s.charAt(i) - '0' ) ) % n;
return result;
}

public static void main(String args[])
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
try
{
do
{
StringBuilder sb = new StringBuilder();
String s;
do
{
s = input.readLine().replaceAll("\\s", "");
sb.append(s);
}
while(!s.contains("#"));
s = sb.deleteCharAt(sb.length() - 1).toString();
if(s.length() != 0)
{
// System.out.println(createFromBinary(s).mod(PRIME) == BigInteger.ZERO? "YES": "NO");
System.out.println(modOfBinary(s, IPRIME) == 0? "YES": "NO");
}
}
while(input.ready());
}
catch(Exception e)
{
}
}
}