zoukankan      html  css  js  c++  java
  • codeforces 887 A题:Div. 64

    A. Div. 64

    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的字符串 , 判断这个 字符串 能不能通过删除一些1或者0 使得剩下的数字是一个整数的二进制表示,并且能够被二进制的 64 整除。

    注意:给出的二进制数字(字符串)可能存在前导零

    思路:64 的二进制表示是:1000000(2) , 从给出的数字的最高位向后找到第一个 1 然后向后统计 0 的个数 num, num大于等于 6 则输出 yes 否则输出 no

    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    
    using namespace std ;
    
    #define maxn 10000 
    char str[maxn] ; 
    
    int main(){
        
        while(~scanf(" %s" , str)){
            int len = strlen(str) ; 
            int num1 = 0 , num2 = 0 ; 
            int flag = 0 ; 
            for(int i=0 ; i<len ; i++){
                if(flag == 0 && str[i] == '1'){
                    flag = 1;  
                }
                if(flag ==1 ) {
                    if(str[i] == '0'){
                        num1 ++ ; 
                    }
                }
            }
            if(num1 >=6 ){
                printf("yes
    ") ; 
            } else printf("no
    ") ; 
        } 
        return 0 ; 
    }
  • 相关阅读:
    javaEE web 系统安装时自定义初始化
    windows 安装绿色版mysql
    myeclipse 安装svn(subeclipsesite)插件
    Xcode连接 Git
    生成16位不重复编码
    百度工程师也犯低级错误(有心还是无意)?
    IBatis 映射文件 sql 中大于、小于等符号转义
    web项目文档总览
    银行卡号的校验
    身份证的校验
  • 原文地址:https://www.cnblogs.com/yi-ye-zhi-qiu/p/7782777.html
Copyright © 2011-2022 走看看