-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path650.py
More file actions
executable file
·49 lines (39 loc) · 793 Bytes
/
650.py
File metadata and controls
executable file
·49 lines (39 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# FileName: 650.py
#
# Description:
#
# Version: 1.0
# Created: 2018-07-17 14:19:30
# Last Modified: 2018-07-18 11:38:14
# Revision: none
# Compiler: gcc
#
# Author: zt ()
# Organization:
def MinSteps2(n):
i = 2
temp = 0
while i <= n:
if n % i == 0:
temp += i
n = n / i
else:
i += 1
return temp
def MinSteps(n):
if n == 1:
return 0
if 2 <= n <= 3:
return n
(x, y) = (1, n)
for i in range(2, n // 2):
v = n / i
if v.is_integer():
(x, y) = (i, int(v))
break
if x == 1:
return y
return MinSteps(x) + MinSteps(y)
print(MinSteps2(18))