1049 Counting Ones (30 分)

The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1's in 1, 10, 11, and 12.

Input Specification:

Each input file contains one test case which gives the positive N (≤2​30​​).

Output Specification:

For each test case, print the number of 1's in one line.

Sample Input:

12

Sample Output:

5

题目大意:给出一个数m,计算1~m中的数包含的所有的1的个数。

//我绝对是看过这道题,但是真的想不起来怎么做了,当时就没怎么看懂。数据量这么大,指定不能一个一个算,需要技巧。

//个位是1+十位是1+。。。。。这样会不会有重复?不会吧。

//这个真的好难,看了好久才明白。

如何计算left和now和right也值得注意!自己求的话就不太会求的。

PAT 1049 Counting Ones [难]的更多相关文章

  1. PAT 1049 Counting Ones[dp][难]

    1049 Counting Ones (30)(30 分) The task is simple: given any positive integer N, you are supposed to ...

  2. pat 1049. Counting Ones (30)

    看别人的题解懂了一些些    参考<编程之美>P132 页<1 的数目> #include<iostream> #include<stdio.h> us ...

  3. pat 1049 Counting Ones

    要统计1到N之间‘1’的个数,如数11包含2个1.所以当N=12时,答案为5. 思想: 找规律,假设ans[N]表示1到N的‘1’的个数,则有a[100]=(a[10]-1)*9+10+a[10]-1 ...

  4. PAT 甲级 1049 Counting Ones (30 分)(找规律,较难,想到了一点但没有深入考虑嫌麻烦)***

    1049 Counting Ones (30 分)   The task is simple: given any positive integer N, you are supposed to co ...

  5. PAT甲级1049. Counting Ones

    PAT甲级1049. Counting Ones 题意: 任务很简单:给定任何正整数N,你应该计算从1到N的整数的十进制形式的1的总数.例如,给定N为12,在1,10, 11和12. 思路: < ...

  6. PAT 解题报告 1049. Counting Ones (30)

    1049. Counting Ones (30) The task is simple: given any positive integer N, you are supposed to count ...

  7. pat 甲级 1049. Counting Ones (30)

    1049. Counting Ones (30) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The tas ...

  8. PAT (Advanced Level) 1049. Counting Ones (30)

    数位DP.dp[i][j]表示i位,最高位为j的情况下总共有多少1. #include<iostream> #include<cstring> #include<cmat ...

  9. PAT甲级1049 Counting Ones【规律】

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805430595731456 题意: 给定n,问0~n中,1的总个数 ...

随机推荐

  1. 模板题 + KMP + 求最小循环节 --- HDU 3746 Cyclic Nacklace

    Cyclic Nacklace Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=3746 Mean: 给你一个字符串,让你在后面加尽 ...

  2. openresty 视频

    http://v.163.com/paike/V8H1BIE6U/V949ER8RD.html#from=search

  3. jquery mobile小经验

    现在网站上关于jquery mobile的demo和帖子可真少啊,我刚开始接触,遇到了一些问题,都找不到人请教. 这是我的个人经验总结,或多或少会对刚入门的童鞋有点帮助吧. 如果想一开始进入页面的时候 ...

  4. PyCharm中设置console端的字体和大小

    file--->setting,选择console Font,右侧primary font即设置console端的字体和大小

  5. ResultSet是结果集对象

    ResultSet是结果集对象 DriverManager管理一组驱动程序 PreparedStatement预编译的,用来发送和执行SQL语句的

  6. 电脑端与iPad 端如何共享ChemDraw结构

    在日常生活中,我们使用的电脑会有好几种系统,很多的软件不能做好各个系统的兼容.但是ChemDraw软件很好的解决了这个问题,可以应用于Mac.Windows两个电脑客户端以及Chem3D for iP ...

  7. mysql关联取附表最后一条记录,附加lareval orm实现

    MySQL 多表关联一对多查询取最新的一条数据:https://blog.csdn.net/u013902368/article/details/86615382 Laravel query buil ...

  8. ItcastOA_整体说明_准备环境

    1. 整体说明 1.1. 项目说明 1.1.1. OA概述 OA是Office Automation的缩写,本意为利用技术的手段提高办公的效率,进而实现办公的自动化处理.实现信息化.无纸化办公,可方便 ...

  9. 合并图片、EUI顺序、CacheAsBitmap对drawcall影响的测试

    一 什么是DrawCall Draw Call 理解和优化: http://blog.csdn.net/sakyaer/article/details/44459881 draw call是openG ...

  10. C 语言开发初涉-01 简单学习

    尝试用C语言写windows程序: 简单的计算器 1.0版,仅用来熟悉C 开发windows的一些语法和语句用法 #include "stdafx.h" #include < ...