UVa 10176 – Ocean Deep! – Make it shallow!!


/*
User ID: turing_13
Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1117
*/

#include <bits/stdc++.h>

#define ll long long
#define sc scanf
#define pf printf
#define Pi 2*acos(0.0)

using namespace std;

int main()
{
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    char ch;
    int num=131071, n=0;
    while((ch=getchar()) !=EOF)
    {
        if(ch=='#')
        {
            if(n==0)
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
            n=0;
        }
        else
        {
            if(ch!='\n')
                n=(n*2+ch-48)%num;
        }
    }
    return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s