Python programming solution to a problem [Blue Bridge Cup official website] DAY5- basic exam training

Digital special basic training questions

Resource limitation
time limit: 1.0s memory limit: 512.0MB
problem description
  153 is a very special number, which is equal to that of cubic and each digit, i.e., 153 = 1 . 1 1 + 5 . 5 5 + 3 . 3 3 All three decimal demand programming to meet this condition.
Output format
  output three decimal number satisfying the condition in ascending order of each number per line.

for i in range(100,1000):
    n,s=i,0
    while n>0:
        s+=pow((n%10),3)
        n=int(n/10)
    if s==i:
        print(i,end="\n")
Published 545 original articles · won praise 129 · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_43838785/article/details/104239484