Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it’s possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisible by 64, in the binary numerical system.
Input
In the only line given a non-empty binary string s with length up to 100.
Output
Print «yes» (without quotes) if it’s possible to remove digits required way and «no» otherwise.
Examples
Input
100010001
Output
yes
Input
100
Output
no
Note
In the first test case, you can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system.
You can read more about binary numeral system representation here: https://en.wikipedia.org/wiki/Binary_system
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int sum=0,i,len,f=0;
char s[105];
scanf("%s",s);
len=strlen(s);
for(i=len-1;i>=0;i--)
{
if(s[i]=='0')
{
sum++;
}
else if(s[i]=='1')
{
if(sum>=6)
{
f=1;
break;
}
}
}
if(f==1)
{
printf("yes\n");
}
else printf("no\n");
return 0;
}
从后面往前数,2的6次方是64,在这之后的都要是0才能满足是64的倍数,但是之前的肯定都是64的倍数了,所以之前的数不用管,只要注意当遇到第一个1时他的后面有6个0就可以了
本文介绍了一种算法,用于判断一个给定的二进制字符串是否可以通过删除某些位,使得剩余部分表示一个能被64整除的正整数。通过从字符串末尾开始检查,确保至少连续六个0跟在一个1之后即可。
741

被折叠的 条评论
为什么被折叠?



