codeforces 887A Div. 64 思维 模拟


A. Div. 64
time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output

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 stringswith length up to100.

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 string1 000 000after removing two ones which is a representation of number64in the binary numerical system.

You can read more about binary numeral system representation here:https://en.wikipedia.org/wiki/Binary_system

思路:

先统计有多少个0,然后从前往后数,遇到第一个1时,判断后面剩余的0的个数是否大于等于6

代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main() {
 4     string s;
 5     cin>>s;
 6     int len=s.length();
 7     int cnt_zero=0;
 8     int cnt_one=0;
 9     for(int i=0;i<len;++i) {
10         if(s[i]=='0') cnt_zero++;
11     }
12     for(int i=0;i<len;++i) {
13         if(s[i]=='0') cnt_zero--;
14         if(s[i]=='1') break;
15     }
16     if(cnt_zero>=6) cout<<"yes"<<endl;
17     else cout<<"no"<<endl;
18     return 0;
19 }
View Code

优质内容筛选与推荐>>
1、material(一)
2、软工网络15结对编程练习
3、动手写个数字输入框2:起手式——拦截非法字符
4、数论 - 学习历程杂碎(1)
5、Friendly Date Ranges (FCC高级算法)


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn