Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def maximum(a):
- b=a[0]
- c=0
- for i in range(1,len(a)):
- if a[i]>b:
- b=a[i]
- c=i
- return c
- def tr(a):
- b=0
- while a!=0:
- a=a//10
- b=b+1
- return b
- n=int(input())
- a=(n-1)*[0]
- for i in range(1,n):
- if i<9:
- a[i-1]=i
- else:
- b=tr(i+1)
- c=0
- for j in range(b-1):
- d=i//10**j%10
- e=i//10**(j+1)%10
- if d>e:
- c=c+d-e
- else:
- c=c+e-d
- a[i-1]=c
- z=maximum(a)
- print(z+1)
Add Comment
Please, Sign In to add comment