#include<bits/stdc++.h>
using namespace std;
int convert(string s)
{
reverse(s.begin(), s.end());
int l = s.size(), i;
unsigned long long int sum = 0, b = 1;
for(i=0; i<l; i++)
{
int a = s[i] - '0';
sum = (sum + (a*b))%131071;
b = (b*2)%131071;
}
return sum;
}
int main()
{
char an;
string p;
unsigned long long int sum = 0, b = 1;
while(cin >> an)
{
if(an == '#')
{
int r = convert(p);
if(r == 0)
cout << "YES" << endl;
else
cout << "NO" << endl;
p.clear();
}
else
{
if(an == '0' || an == '1')
p = p + an;
}
}
return 0;
}
using namespace std;
int convert(string s)
{
reverse(s.begin(), s.end());
int l = s.size(), i;
unsigned long long int sum = 0, b = 1;
for(i=0; i<l; i++)
{
int a = s[i] - '0';
sum = (sum + (a*b))%131071;
b = (b*2)%131071;
}
return sum;
}
int main()
{
char an;
string p;
unsigned long long int sum = 0, b = 1;
while(cin >> an)
{
if(an == '#')
{
int r = convert(p);
if(r == 0)
cout << "YES" << endl;
else
cout << "NO" << endl;
p.clear();
}
else
{
if(an == '0' || an == '1')
p = p + an;
}
}
return 0;
}
Comments
Post a Comment