-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathpython_template.py
More file actions
62 lines (54 loc) · 890 Bytes
/
python_template.py
File metadata and controls
62 lines (54 loc) · 890 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
50
51
52
53
54
55
56
57
58
59
60
61
62
#AUTHOR : BHUVNESH JAIN
#INSTITUTION : BITS, PILANI
from math import *
MAX = 100005
MOD = 1000000007
def add(a,b,c):
res=a+b
if(res>=c):
return res-c
else:
return res
def mod(a,b,c):
res=a*b
if(res>=c):
return res%c
else:
return res
def gcd(a,b):
while b:
a,b=b,a%b
return a
def lcm(a,b):
w=a//gcd(a,b)
return w*b
def expo(a,b):
x,y=1,a
while(b>0):
if(b&1):
x=x*y
y=y*y
b>>=1
return x
def power(a,b,m):
x,y=1,
while(b>0):
if(b&1):
x=mod(x,y,m)
y=mod(y,y,m)
b>>=1
return x
def alldivisors(n) :
list = []
arr = []
for i in range(1, int(sqrt(n) + 1)) :
if (n % i == 0):
if (n / i == i) :
arr+=[i]
else:
arr+=[i]
list.append(n//i)
arr += list[::-1]
return arr
if __name__ == "__main__":
#code goes below