CF2197A.Friendly Numbers

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

For an integer xx, we call another integer yy friendly if the following condition holds:

  • y−d(y)=xy - d(y) = x, where d(y)d(y) is the sum of the digits of yy.

For a given integer xx, determine how many friendly numbers it has.

对于一个整数 xx,若另一个整数 yy 满足以下条件,则称 yy 是 xx 的“友好数”:

  • y−d(y)=xy - d(y) = x,其中 d(y)d(y) 表示 yy 的各位数字之和。

给定一个整数 xx,请确定 xx 有多少个友好数。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤5001 \le t \le 500). The description of the test cases follows.

Each test case consists of a single line containing one integer xx (1≤x≤1091 \le x \le 10^{9}).

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤5001 \le t \le 500)。随后是各测试用例的描述。

每个测试用例由一行组成,其中包含一个整数 xx(1≤x≤1091 \le x \le 10^{9})。

输出格式

For each test case, output one integer — the answer to the problem.

对于每个测试用例,输出一个整数——该问题的答案。

输入输出样例

  • 输入#1

    3
    1
    18
    998244360

    输出#1

    0
    10
    10

说明/提示

The number 11 does not have any friendly numbers.

The number 1818 has 1010 friendly numbers: These are all the numbers from 2020 to 2929. For example, 20−d(20)=20−2=1820 - d(20) = 20 - 2 = 18.

The number 998 244 360998\,244\,360 has 1010 friendly numbers:

  • 998 244 400998\,244\,400
  • 998 244 401998\,244\,401
  • 998 244 402998\,244\,402
  • 998 244 403998\,244\,403
  • 998 244 404998\,244\,404
  • 998 244 405998\,244\,405
  • 998 244 406998\,244\,406
  • 998 244 407998\,244\,407
  • 998 244 408998\,244\,408
  • 998 244 409998\,244\,409

数字 11 没有任何友好数。

数字 1818 有 1010 个友好数:这些数恰好是从 2020 到 2929 的所有整数。例如,20−d(20)=20−2=1820 - d(20) = 20 - 2 = 18。

数字 998 244 360998\,244\,360 有 1010 个友好数:

  • 998 244 400998\,244\,400
  • 998 244 401998\,244\,401
  • 998 244 402998\,244\,402
  • 998 244 403998\,244\,403
  • 998 244 404998\,244\,404
  • 998 244 405998\,244\,405
  • 998 244 406998\,244\,406
  • 998 244 407998\,244\,407
  • 998 244 408998\,244\,408
  • 998 244 409998\,244\,409

输入解题思路,AI测评打分。不知道怎么写?

首页