鱼C论坛

 找回密码
 立即注册
查看: 2338|回复: 1

题目156:统计数字个数

[复制链接]
发表于 2016-9-13 14:51:11 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 永恒的蓝色梦想 于 2020-7-31 10:36 编辑
Counting Digits

Starting from zero the natural numbers are written down in base 10 like this:
0 1 2 3 4 5 6 7 8 9 10 11 12....

Consider the digit d=1. After we write down each number n, we will update the number of ones that have occurred and call this number f(n,1). The first values for f(n,1), then, are as follows:

n f(n,1)
0        0
1        1
2        1
3        1
4        1
5        1
6        1
7        1
8        1
9        1
10        2
11        4
12        5

Note that f(n,1) never equals 3.
So the first two solutions of the equation f(n,1)=n are n=0 and n=1. The next solution is n=199981.

In the same manner the function f(n,d) gives the total number of digits d that have been written down after the number n has been written.
In fact, for every digit d ≠ 0, 0 is the first solution of the equation f(n,d)=n.

Let s(d) be the sum of all the solutions for which f(n,d)=n.
You are given that s(1)=22786974071.

Find ∑ s(d) for 1 ≤ d ≤ 9.

Note: if, for some n, f(n,d)=n for more than one value of d this value of n is counted again for every value of d for which f(n,d)=n.


题目:

从 0 开始的 10 进制数如下:
0  1  2  3  4  5  6  7  8  9  10  11  12 ....

考虑 d=1,我们每写下一个数字,就更新数字1出现的次数,并且把这个数字叫做 f(n,1)。f(n,1) 的一些值如下:

n f(n,1)
0        0
1        1
2        1
3        1
4        1
5        1
6        1
7        1
8        1
9        1
10        2
11        4
12        5


注意,f(n,1) 永远不等于 3。

所以,f(n,1)=n 的前两个解为 n=0 和 n=1,下一个解就是 n=199981.

f(n,d) 以同样的方式,定义为从 1 写到 n 时,数字 d 的出现次数。

实际上,对于方程 f(n,d)=n,只要 d 不等于 0,0 就是方程的第一个解。

定义 s(d) 为 f(n,d)=n 所有解的和。

已知,s(1)=22786974071

对于 1 ≤ d ≤ 9,求 ∑ s(d)

注意:如果对于一些 n 来说,它能对不同的 d 都满足方程 f(n,d)=n,那么它每次满足方程时,都要进行统计。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-4-21 21:20:42 | 显示全部楼层
这个题目看来只有死做了。耗时比较厉害。
答案:
s(1):22786974071
s(2):73737982962
s(3):372647999625
s(4):741999999540
s(5):100000000000
s(6):2434703999430
s(7):1876917059570
s(8):15312327487352
s(9):360000000000
Sum=21295121502550
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-2 21:42

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表