题目链接

http://codeforces.com/contest/9/problem/C

题目大意

输入n,计算出n之内只有0和1组成的数字的数量

分析

k从1开始,只要小于n,就给sum++,并给k加上1,而k用go函数模拟二进制的进位

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int k;
void go()
{     int i,j;
      i=1,j=1;
      int ok=1;
      k+=1;
      while(ok){
          if(k/j%10<2)ok=0;
            else {
                k=1*i*10+k-2*i;
                i*=10;
            j*=10;
          }
      }
}
int main()
{     int n,m,i,j,sum=0;
      cin>>n;
      k=1;
      while(k<=n){
          sum++;
          go();
      }
      cout<<sum<<endl;
      return 0;
}

9 C. Hexadecimal's Numbers的更多相关文章

  1. codeforces 9 div2 C.Hexadecimal's Numbers 暴力打表

    C. Hexadecimal's Numbers time limit per test 1 second memory limit per test 64 megabytes input stand ...

  2. Codeforces Beta Round #9 (Div. 2 Only) C. Hexadecimal's Numbers dfs

    C. Hexadecimal's Numbers 题目连接: http://www.codeforces.com/contest/9/problem/C Description One beautif ...

  3. C. Hexadecimal's Numbers

    C. Hexadecimal's Numbers time limit per test 1 second memory limit per test 64 megabytes input stand ...

  4. Codeforce 9C - Hexadecimal's Numbers

    One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got ...

  5. Codeforces 9C Hexadecimal's Numbers - 有技巧的枚举

    2017-08-01 21:35:53 writer:pprp 集训第一天:作为第一道题来讲,说了两种算法, 第一种是跟二进制数联系起来进行分析: 第二种是用深度搜索来做,虽然接触过深度搜索但是这种题 ...

  6. SH Script Grammar

    http://linux.about.com/library/cmd/blcmdl1_sh.htm http://pubs.opengroup.org/onlinepubs/9699919799/ut ...

  7. man bash

    BASH(1) General Commands Manual BASH(1) NAME bash - GNU Bourne-Again SHell SYNOPSIS bash [options] [ ...

  8. dhcpd.conf(5) - Linux man page

    http://linux.die.net/man/5/dhcpd.conf Name dhcpd.conf - dhcpd configuration file Description   The d ...

  9. bash5.0参考手册

    Bash Reference Manual a.summary-letter { text-decoration: none } blockquote.indentedblock { margin-r ...

随机推荐

  1. Linux内核打印时间戳

    较为简单可行的方式是通过PrintkTime功能为启动过程的所有内核信息增加时间戳,便于汇总分析.PrintkTime最早为CELF所提供的一个内核补丁,在后来的Kernel 2.6.11版本中正式纳 ...

  2. Swagger文档转Word 文档

    GitHub 地址:https://github.com/JMCuixy/SwaggerToWord/tree/developer 原创作品,转载请注明出处:http://www.cnblogs.co ...

  3. CVE-2017-8635复现

    在最近几个月里,我花了一些时间深入了Device Guard以及如何实现用户模式代码完整性(UMCI).如果您对Device Guard不熟悉,您可以 在这里阅读更多信息.通常情况下,UMCI可防止未 ...

  4. HUST 1585 排队

    1585 - 排队 时间限制:1秒 内存限制:128兆 351 次提交 179 次通过 题目描述 BG站在一个有n个人的队伍中,但他并不知道他处于队伍中的哪个位置,他向前向后观察,只能断定他的前方有至 ...

  5. 【WC2013】糖果公园

    Candyland 有一座糖果公园,公园里不仅有美丽的风景.好玩的游乐项目,还有许多免费糖果的发放点,这引来了许多贪吃的小朋友来糖果公园玩. 糖果公园的结构十分奇特,它由 nn 个游览点构成,每个游览 ...

  6. Gym 100952B&&2015 HIAST Collegiate Programming Contest B. New Job【模拟】

    B. New Job time limit per test:1 second memory limit per test:64 megabytes input:standard input outp ...

  7. JXLS 2.4.0系列教程(三)——嵌套循环是怎么做到的

    注:本文代码在第一篇文章基础上修改而成,请务必先阅读第一篇文章. http://www.cnblogs.com/foxlee1024/p/7616987.html 本文也不会过多的讲解模板中遍历表达式 ...

  8. mysql中OPTIMIZE TABLE的作用

    转载▼ 1.先来看看多次删除插入操作后的表索引情况 mysql> SHOW INDEX FROM `tbl_name`; +----------+------------+----------- ...

  9. [转载]织梦CMS首页调用分类信息栏目及列表方法

    原文地址:织梦CMS首页调用分类信息栏目及列表方法作者:小武哥 不懂代码,搜索学习一晚上,都是说调用特定栏目分类信息列表的,用这个代码 {dede:arclistsg row='10' titlele ...

  10. HttpUrlConnection使用与总结

    /*     * URL请求的类别分为二类,GET与POST请求.二者的区别在于:      * a:) get请求可以获取静态页面,也可以把参数放在URL字串后面,传递给servlet,      ...