CF2197A.Friendly Numbers
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For an integer x, we call another integer y friendly if the following condition holds:
- y−d(y)=x, where d(y) is the sum of the digits of y.
For a given integer x, determine how many friendly numbers it has.
对于一个整数 x,若另一个整数 y 满足以下条件,则称 y 是 x 的“友好数”:
- y−d(y)=x,其中 d(y) 表示 y 的各位数字之和。
给定一个整数 x,请确定 x 有多少个友好数。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤500). The description of the test cases follows.
Each test case consists of a single line containing one integer x (1≤x≤109).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤500)。随后是各测试用例的描述。
每个测试用例由一行组成,其中包含一个整数 x(1≤x≤109)。
输出格式
For each test case, output one integer — the answer to the problem.
对于每个测试用例,输出一个整数——该问题的答案。
输入输出样例
输入#1
3 1 18 998244360
输出#1
0 10 10
说明/提示
The number 1 does not have any friendly numbers.
The number 18 has 10 friendly numbers: These are all the numbers from 20 to 29. For example, 20−d(20)=20−2=18.
The number 998244360 has 10 friendly numbers:
- 998244400
- 998244401
- 998244402
- 998244403
- 998244404
- 998244405
- 998244406
- 998244407
- 998244408
- 998244409
数字 1 没有任何友好数。
数字 18 有 10 个友好数:这些数恰好是从 20 到 29 的所有整数。例如,20−d(20)=20−2=18。
数字 998244360 有 10 个友好数:
- 998244400
- 998244401
- 998244402
- 998244403
- 998244404
- 998244405
- 998244406
- 998244407
- 998244408
- 998244409
输入解题思路,AI测评打分。不知道怎么写?