zoukankan      html  css  js  c++  java
  • 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 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

    思路:

    先统计有多少个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
  • 相关阅读:
    vue中的watch
    css渲染层次理解及实际问题
    css中一些设计总结
    python打包文件(nuitka)
    vue实现前后端文件的上传和下载
    pyqt5使用多线程避免程序假死
    使用python编写shell脚本并运行
    记录一下WordNet多线程下的bug
    利用多线程对大数组进行处理
    nginx配置静态文件
  • 原文地址:https://www.cnblogs.com/lemonbiscuit/p/7783187.html
Copyright © 2011-2022 走看看