Skip to content

Commit

Permalink
problem 7 update
Browse files Browse the repository at this point in the history
  • Loading branch information
harrypotter0 committed Jan 18, 2018
1 parent ea0e3f1 commit 856b331
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Empty file.
5 changes: 5 additions & 0 deletions CP/Practice/medium/flip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
n,m = map(int,raw_input().split())
for _ in range(m):
a = map(int,raw_input().split())
if(a[0]==0):

37 changes: 37 additions & 0 deletions CP/Practice/medium/numfact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
primes = [2,3,5,7]
for i in range(11,1000):
isPrime = True
for j in primes:
if i%j == 0:
isPrime = False
break
if isPrime:
primes.append(i)
numberOfPrimes = len(primes)


for _ in range(input()):
n = input()
a = map(int, raw_input().split())
d = {}
for i in a:
j = 0
while j<numberOfPrimes and primes[j]<= i:
while i%primes[j] == 0:
i/=primes[j]
if primes[j] in d:
d[primes[j]] += 1
else:
d[primes[j]] = 2
j+=1
#print(d,i)
if i!=1:
if i in d:
d[i] += 1
else:
d[i] = 2

answer = 1
for key in d:
answer*=d[key]
print answer

0 comments on commit 856b331

Please sign in to comment.