-
Notifications
You must be signed in to change notification settings - Fork 1
/
gu-ito-1-14.py
33 lines (28 loc) · 949 Bytes
/
gu-ito-1-14.py
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
class FactorFinder:
def __init__(self, n):
self.n = n
def find_factors(self):
def backtrack(remaining, start, path, result):
#..... YOUR CODE STARTS HERE .....
if remaining == 1:
if len(path) > 1:
result.append(path[ : ])
else:
result.append([1, path[0]])
return
for i in range(start, remaining + 1):
if remaining % i ==0:
path.append(i)
backtrack(remaining // i,i,path,result)
path.pop()
result = []
backtrack(self.n,2,[],result)
return result
#..... YOUR CODE ENDS HERE .....
result = []
backtrack(self.n, 2, [], result)
return result
if __name__ == '__main__':
n = int(input())
factor_finder = FactorFinder(n)
print(factor_finder.find_factors())