• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Feb 14th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2.
3. maxs = 0
4. flag = 0
5. def number(n , digit, start, total):
6.     global maxs
7.     global flag
8.     if digit == 0:
9.         flag = 1
10.         maxs = int(total)
11.         return
12.
13.     for i in range(9 , -1, -1):
14.         cur = total
15.         if i > n:
16.             continue
17.         if start == digit and i == 0:
18.             continue
19.         cur +=  str(i)
20.
21.         number(n - i, digit - 1, start, cur)
22.         if flag == 1:
23.             return
24.
25. if flag == 0:
26.     maxs = -1
27.
28. mins = -1
29. flagmin = 0
30. def numbermin(n , digit, start, total):
31.     global mins
32.     global flagmin
33.     if digit == 0:
34.         flagmin = 1
35.         mins = int(total)
36.         return
37.
38.     for i in range(0 , 10):
39.         cur = total
40.
41.         if start == digit and i == 0:
42.             continue
43.
44.         cur +=  str(i)
45.
46.         number(n - i, digit - 1, start, cur)
47.         if flagmin == 1:
48.             return
49.
50. print(flagmin)
51. numbermin(15, 2, 2, "")
52.
53.
54.
55. print(mins)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top