21310_NivenNumbers

2022-5-16 18:19| 发布者: Hocassian| 查看: 50| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505131247300-Problem List-采集的数据-后羿采集器.html

Pro.ID

21310

Title

Niven Numbers

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21310

AC

57

Submit

110

Ratio

51.82%

时间&空间限制

  • Time Limit: 400/200 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    A Niven number is a number such that the sum of its digits divides itself. For example, 111 is a Niven number because the sum of its digits is 3, which divides 111. We can also specify a number in another base b, and a number in base b is a Niven number if the sum of its digits divides its value.

    Given b (2 ≤ b ≤ 10) and a number in base b, determine whether it is a Niven number or not.

    输入

    Each line of input contains the base b, followed by a string of digits representing a positive integer in that base. There are no leading zeroes. The input is terminated by a line consisting of 0 alone.

    输出

    Description

    A Niven number is a number such that the sum of its digits divides itself. For example, 111 is a Niven number because the sum of its digits is 3, which divides 111. We can also specify a number in another base b, and a number in base b is a Niven number if the sum of its digits divides its value.

    Given b (2 ≤ b ≤ 10) and a number in base b, determine whether it is a Niven number or not.

    Input

    Each line of input contains the base b, followed by a string of digits representing a positive integer in that base. There are no leading zeroes. The input is terminated by a line consisting of 0 alone.

    Output

    For each case, print "yes" on a line if the given number is a Niven number, and "no" otherwise.

    Sample Input

    10 111
    2 110
    10 123
    6 1000
    8 2314
    0

    Sample Output

    yes
    yes
    no
    yes
    no

    Source

    样例输入

    10 111
    2 110
    10 123
    6 1000
    8 2314
    0

    样例输出

    yes
    yes
    no
    yes
    no

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部