UVa 10176 - Ocean Deep! - Make it shallow!!
#include<bits/stdc++.h>
using namespace std;
int main()
{
int number=0 , p = 131071;
char ch;
while(cin >> ch)
{
if(ch=='#')
{
if(number)
{
cout << "NO\n";
}
else
{
cout << "YES\n";
}
number = 0;
continue;
}
number = (number * 2) + (ch-48); // make a number from binary to decimal
number%=p;
}
return 0;
}
using namespace std;
int main()
{
int number=0 , p = 131071;
char ch;
while(cin >> ch)
{
if(ch=='#')
{
if(number)
{
cout << "NO\n";
}
else
{
cout << "YES\n";
}
number = 0;
continue;
}
number = (number * 2) + (ch-48); // make a number from binary to decimal
number%=p;
}
return 0;
}
Comments
Post a Comment