zoukankan      html  css  js  c++  java
  • Codeforces Round #444 (Div. 2)A. 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的字符串 , 判断这个 字符串 能不能通过删除一些1或者0 使得剩下的数字是一个整数的二进制表示,并且能够被二进制的 64 整除。

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

    【代码】:

    #include <bits/stdc++.h>
    
    using namespace std;
    char s[11000];
    int main()
    {
        scanf("%s",s);
        int flag=0,cnt=0;
        for(int i=0;i<strlen(s);i++)
        {
            if(flag==0 && s[i]=='1')
            {
                flag=1;
            }
            if(flag)
            {
                if(s[i]=='0')
                {
                    cnt++;
                }
            }
        }
        if(cnt>=6)
            printf("yes
    ");
        else
            printf("no
    ");
        return 0;
    }
    View Code
  • 相关阅读:
    一个可以用的Lua的Class函数
    写一个可以用的Lua打印Table的函数
    关于C#的接口的碎碎念
    C#中接口是值类型还是引用类型?
    Effective C++笔记_条款31将文件间的编译依存关系降至最低
    Effective C++ 阅读笔记_条款27 尽量少做转型动作
    Flask--开发全套
    python之元类
    Django之模板层
    go打开文件
  • 原文地址:https://www.cnblogs.com/Roni-i/p/7788410.html
Copyright © 2011-2022 走看看