A

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

题意:

给出一个小于100位的二进制数,判断移走任意个数的数字之后,能否变成一个能被64整除的数字。

解题思路:

直接数0的个数就好,注意这里的0需要在一个1出现以后才有效。

代码:

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 int main()
 5 {
 6     string s;
 7     cin>>s;
 8     int zero=0;
 9     int one=0;
10     int flag=0;
11     for(int i=0;i<s.size();i++)
12     {
13         if(s[i]=='0'&&flag)
14             zero++;
15         if(s[i]=='1')
16         {
17             one++;flag=1;
18         }
19     }
20     if(zero>=6&&one>=1)
21         printf("yes
");
22     else
23         printf("no
");
24     return 0;
25 }
A - Div.64
まだまだだね
原文地址:https://www.cnblogs.com/xxQ-1999/p/7803609.html