题目链接

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. [PHP] PHP源码常用代码中的宏定义

    PHP源码常用代码宏定义:#define 宏名 字符串#表示这是一条预处理命令,所有的预处理命令都以#开头.define是预处理命令.宏名是标识符的一种,命名规则和标识符相同.字符串可以是常数.表达式 ...

  2. HttpWebRequest中GetResponse或者说GetRequestStream偶尔超时,或者是各种操作超时造成的假死的一些解决方案

    今天用了将近一天的时间来查找这个问题的存在,不停的百度查找原因测试原因,发现解决方案很是简单,不过最好还好哦啊都解决了,在这里纪录一下,希望可以帮到你们 payload = System.Text.E ...

  3. 13、ABPZero系列教程之拼多多卖家工具 微信公众号开发前的准备

    因为是开发阶段,我需要在本地调试,而微信开发需要配置域名,这样natapp.cn就有了用武之地,应该说natapp就是为此而生的. natapp.cn是什么 这是一个内网映射的网站,支持微信公众号.小 ...

  4. BZOJ1758: [Wc2010]重建计划(01分数规划+点分治+单调队列)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1758 01分数规划,所以我们对每个重心进行二分.于是问题转化为Σw[e]-mid>=0, ...

  5. BC#64 4.Tree

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5589 对于u,v的xor和就是u到根的xor和 xor上 v到根的xor和.看到n<=5w,考虑莫队 ...

  6. 【Keras】基于SegNet和U-Net的遥感图像语义分割

    上两个月参加了个比赛,做的是对遥感高清图像做语义分割,美其名曰"天空之眼".这两周数据挖掘课期末project我们组选的课题也是遥感图像的语义分割,所以刚好又把前段时间做的成果重新 ...

  7. cookie 和 session的区别

    一.总结: 1.cookie数据存放在客户的浏览器上,session数据放在服务器上. 2.cookie不是很安全,别人可以分析存放在本地的COOKIE并进行COOKIE欺骗 考虑到安全应当使用ses ...

  8. 属性getter和setter

    我们知道,对象属性是由名字.值和一组特性(attribute)构成的.在ECMAScript5 中,属性值可以用一个或两个方法替代,这两个方法就是getter和setter.由getter和sette ...

  9. Unity Object Pool

    using System.Collections; using System.Collections.Generic; using UnityEngine; [System.Serializable] ...

  10. 微信公众平台宣布增加接口IP白名单提高安全性

    微信公众平台目前已经发布通知在平台接口调用上为了提高安全性需要添加IP白名单并仅允许白名单IP调用. 目前微信公众平台面向开发者主要提供的开发者ID和开发者密钥,在调用时ID和密钥通过检验即可进行调用 ...