A7784 | Digital Root
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Not long ago Billy came across such a problem, where there were given three natural numbers $A$ , $B$ and $C$ from the range $[1,N]$ , and it was asked to check whether the equation $AB=C$ is correct. Recently Billy studied the concept of a digital root of a number. We should remind you that a digital root $d(x)$ of the number $x$ is the sum $s(x)$ of all the digits of this number, if $s(x)<=9$ , otherwise it is $d(s(x))$ . For example, a digital root of the number 6543 is calculated as follows: $d(6543)=d(6+5+4+3)=d(18)=9$ . Billy has counted that the digital root of a product of numbers is equal to the digital root of the product of the factors' digital roots, i.e. $d(xy)=d(d(x)d(y))$ . And the following solution to the problem came to his mind: to calculate the digital roots and check if this condition is met. However, Billy has doubts that this condition is sufficient. That's why he asks you to find out the amount of test examples for the given problem such that the algorithm proposed by Billy makes mistakes.
不久前,Billy 遇到了这样一个问题:给定了三个自然数 $A$、$B$ 和 $C$,范围在 $[1, N]$,问题是要检查方程 $AB = C$ 是否正确。最近 Billy 学习了数字的数根概念。我们应该提醒你,数字 $x$ 的数根 $d(x)$ 是这个数字所有数字的总和 $s(x)$,如果 $s(x) ≤ 9$,否则它是 $d(s(x))$。例如,数字 6543 的数根计算如下:$d(6543) = d(6 + 5 + 4 + 3) = d(18) = 9$。Billy 计算出数字的乘积的数根等于因子的数根的乘积的数根,即 $d(xy) = d(d(x)d(y))$。他想到了以下解决问题的方法:计算数根并检查是否满足这个条件。然而,Billy 怀疑这个条件是否足够。这就是为什么他要求你找出给定问题的测试示例数量,使得 Billy 提出的算法出错。
感谢[Macw](https://www.acgo.cn/person/929871)提供翻译
不久前,Billy 遇到了这样一个问题:给定了三个自然数 $A$、$B$ 和 $C$,范围在 $[1, N]$,问题是要检查方程 $AB = C$ 是否正确。最近 Billy 学习了数字的数根概念。我们应该提醒你,数字 $x$ 的数根 $d(x)$ 是这个数字所有数字的总和 $s(x)$,如果 $s(x) ≤ 9$,否则它是 $d(s(x))$。例如,数字 6543 的数根计算如下:$d(6543) = d(6 + 5 + 4 + 3) = d(18) = 9$。Billy 计算出数字的乘积的数根等于因子的数根的乘积的数根,即 $d(xy) = d(d(x)d(y))$。他想到了以下解决问题的方法:计算数根并检查是否满足这个条件。然而,Billy 怀疑这个条件是否足够。这就是为什么他要求你找出给定问题的测试示例数量,使得 Billy 提出的算法出错。
感谢[Macw](https://www.acgo.cn/person/929871)提供翻译
输入格式
The first line contains the only number $N$ ( $1<=N<=10^{6}$ ).
输入一个整数 $N (1 \le N \le 10^6)$。
输入一个整数 $N (1 \le N \le 10^6)$。
输出格式
Output one number — the amount of required $A$ , $B$ and $C$ from the range $[1,N]$ .
输出一个整数,表示在询问区间内满足条件的$A, B, C$的个数。
输出一个整数,表示在询问区间内满足条件的$A, B, C$的个数。
输入输出样例
输入 #1
4
输出 #1
2
输入 #2
5
输出 #2
6
For the first sample the required triples are $(3,4,3)$ and $(4,3,3)$ .
**请注意,本题时间限制为2s,是默认时间限制的两倍。空间限制为256MB,是默认空间限制的两倍。**
**请注意,本题时间限制为2s,是默认时间限制的两倍。空间限制为256MB,是默认空间限制的两倍。**
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted