Skip to content

Instantly share code, notes, and snippets.

@knuu
Created November 7, 2015 07:31
Show Gist options
  • Save knuu/936895147d131b2dc5ba to your computer and use it in GitHub Desktop.
Save knuu/936895147d131b2dc5ba to your computer and use it in GitHub Desktop.
SRM 643 div.2 500 / div.1 250 TheKingsFactorization
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
class TheKingsFactorization:
def getVector(self, N, primes):
ans = list(primes)
n = N
for p in primes:
n /= p
i = 2
while i ** 3 <= N:
while n % i == 0:
n /= i
ans.append(i)
i += 1
if n > 1:
ans.append(n)
return tuple(sorted(ans))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment