博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1049. Counting Ones (30)计算个位数出现次数.
阅读量:4071 次
发布时间:2019-05-25

本文共 534 字,大约阅读时间需要 1 分钟。

传送门:

#include 
#include
#include
#include
#include
#include
#include
#include
using namespace std;int a[10]={0};void deal(int n,int value){ if(n<=0) return; int one,ten; one = n%10; n/=10; ten=n; for (int i=0; i<=one; ++i) {//个位上出现的数统计下来 a[i]+=value; } while (ten) { a[ten%10]+= (one+1)*value; ten/=10; } for (int i=0; i<10; ++i) { a[i]+=value*n; } a[0]-=value;//第一位是0的情况排除. deal(n-1,value*10);}int main(){ int n; scanf("%d",&n); deal(n,1); printf("%d\n",a[1]); return 0;}

转载地址:http://mqhji.baihongyu.com/

你可能感兴趣的文章
hd printer lexmark / dazifuyin / dayin / fuyin
查看>>
OS + Unix IBM Aix basic / topas / nmon / filemon / vmstat / iostat / sysstat/sar
查看>>
my ReadMap subway / metro / map / ditie / gaotie / traffic / jiaotong
查看>>
OS + Linux DNS Server Bind
查看>>
自定义切面会吃掉异常,导致事务不生效的问题。
查看>>
我们发送一个请求时,服务端的javax.servlet.http.HttpServletRequest帮我们做了什么?
查看>>
一、实现多线程的三种方式
查看>>
新手报到第一天
查看>>
折半查找法
查看>>
VirtualBox安装Centos6.4不能为虚拟电脑打开一个新的任务
查看>>
Virtual 下安装CentOs6.4
查看>>
CentOS下配置软RAID
查看>>
GET http://test01.com/jquery-1.9.1.min.js [HTTP/1.1 404 Not Found 3ms]
查看>>
echo(),print(),print_r()之间的区别?
查看>>
jQuery中$('#selector).html('')是清空??----html()、text()、val()的区别
查看>>
欢迎使用CSDN-markdown编辑器
查看>>
Python使用web.py读取Mysql的数据
查看>>
web.py操作mysql的数据
查看>>
python类的详析
查看>>
web.py的两种更新Mysql数据的方法
查看>>