Problem:


Score : 300 points

Problem Statement

You are given an integer N.
Find the number of the positive divisors of N!, modulo 10^9+7.

Constraints

1≤N≤10^3

Input

The input is given from Standard Input in the following format:

N

Output

Print the number of the positive divisors of N!, modulo 10^9+7.

Sample Input 1

3

Sample Output 1

4

There are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.

Sample Input 2

6

Sample Output 2

30

Sample Input 3

1000

Sample Output 3

972926972



Sample input:
3


Sample output:
4

Submission status: Accepted

Solution code:
from operator import mul
from functools import reduce
def PrimeDecomp(N,ConcFlag):
    if ConcFlag:
        if N<=1:
            return [1],1
        else:
            I = 2
            PrimeDec = []
            DivCount = 1
            while I*I<=N:
                Cnt = 0
                while N%I==0:
                    N //= I
                    PrimeDec.append(I)
                DivCount *= (Cnt+1)
                I += 1
            if N>=2:
                PrimeDec.append(N)
                DivCount *= 2
            return PrimeDec,DivCount        
    else:
        if N<=1:
            return [1],[1],1
        else:
            I = 2
            PrimeDec = []
            PrimeCnt = []
            DivCount = 1
            while I*I<=N:
                Cnt = 0
                while N%I==0:
                    N //= I
                    Cnt += 1
                if Cnt>=1:
                    PrimeDec.append(I)
                    PrimeCnt.append(Cnt)
                    DivCount *= (Cnt+1)
                I += 1
            if N>=2:
                PrimeDec.append(N)
                PrimeCnt.append(1)
                DivCount *= 2
            return PrimeDec,PrimeCnt,DivCount

def DivisorFactorial(N,FactDec,FactCnt,MemoFlag):
    if MemoFlag:
        if N<=1:
            FDivCnt = 1
            return FactDec,FactCnt,FDivCnt
        else:
            PrimeDec,PrimeCnt,_ = PrimeDecomp(N,False)
            for TP in range(0,len(PrimeDec)):
                if PrimeDec[TP] in set(FactDec):
                    FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
                else:
                    FactDec.append(PrimeDec[TP])
                    FactCnt.append(PrimeCnt[TP])
            FDivCnt = reduce(mul,[(T+1) for T in FactCnt])
            return FactDec,FactCnt,FDivCnt
    else:
        if N<=1:
            FDivCnt = 1
            return FactDec,FactCnt,FDivCnt
        else:
            for TN in range(2,N+1): 
                PrimeDec,PrimeCnt,_ = PrimeDecomp(TN,False)
                for TP in range(0,len(PrimeDec)):
                    if PrimeDec[TP] in set(FactDec):
                        FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
                    else:
                        FactDec.append(PrimeDec[TP])
                        FactCnt.append(PrimeCnt[TP])
            FDivCnt = reduce(mul,[(T+1) for T in FactCnt])
            return FactDec,FactCnt,FDivCnt
          
N = int(input())
FactDec,FactCnt,FDivCnt = DivisorFactorial(N,[],[],False)
print(FDivCnt%(10**9+7))

Submission status: Accepted

Solution code:
n=int(input())
m=10**9+7
p=[1 for i in range(10000)]
p[0]=0
p[1]=0
for i in range(2,n+1):
  if p[i]==1:
    for j in range(i*i,n+1,i):
        p[j]=0
ans=1
for i in range(2,n+1):
  if p[i]:
    c=0
    k=i
    while n//k>0:
      c=c+(n//k)%m
      k=k*i
    ans=(ans*((c+1)%m))%m
print(ans%m)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
mod = 10**9 + 7
f = defaultdict(int)

def fctr1(n):
    c = 0
    r = int(n**0.5)
    for i in range(2, r+2):
        while n % i == 0:
            c += 1
            n = n//i
        if c != 0:
            f[i] += c
            c = 0
    if n != 1:
        f[n] += 1
    return f


for i in range(1, n+1):
    f = fctr1(i)

ans = 1
for v in f.values():
    ans = ans * (v+1) % mod
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ji = {}
ans = 1
for i in range(n):
    tmp = i + 1
    j = 2
    while tmp != 1:
        if tmp % j == 0:
            if not j in ji:
                ji[j] = 0
            
            ji[j] += 1
            tmp /= j
        else:
            j += 1 

for i in ji.values():
    ans *= (i + 1)

print(ans % 1000000007)

Submission status: Accepted

Solution code:
n = int(input())

ji = {}
ans = 1
m = 1000000007
for i in range(n):
    tmp = i + 1
    j = 2
    while tmp != 1:
        if tmp % j == 0:
            if not j in ji:
                ji[j] = 0
            
            ji[j] += 1
            tmp /= j
        else:
            j += 1 

for i in ji.values():
    ans *= (i + 1)
    ans %= m
    

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    D = defaultdict(int)
    if N == 1:
        print(1)
        exit()

    for n in range(2, N+1):
        ND = prime_fact(n)
        for p, a in list(ND.items()):
            D[p] += a

    ans = 1
    for p, a in list(D.items()):
        ans = ans * (a+1) % MOD
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from math import factorial

n = int(input())
f = factorial(n)

mod = 10 ** 9 + 7

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

ans = 1
for p in primes(n):
    temp = 1
    while f % p == 0:
        temp += 1
        f //= p
    ans = (ans * temp) % mod
print(ans)

Submission status: Accepted

Solution code:
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-16 22:01
# @url:https://atcoder.jp/contests/abc052/tasks/arc067_a
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n=int(input())
    mod=10**9+7
    d=[0]*(n+1)
    def check(x):
        for i in range(2,math.ceil(math.sqrt(x))+1):
            if x%i==0:
                return False
        return True
    q=[2]
    for j in range(3,1001):
        if check(j):
            q.append(j)
    while n>1:
        temp=n
        while temp!=1:
            for i in q:
                if temp%i==0:
                    d[i]+=1
                    temp=temp//i
                    break
        n=n-1
    ans=1
    for x in d:
        if x!=0:
            ans=ans*(x+1)
    print (ans%mod)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
prime = [2, 3, 5]
for i in range(7, 1001, 2):
  sqi = math.sqrt(i)
  for j in prime:
    if i % j == 0:
      break
    if sqi < j:
      prime.append(i)
      break

def legendre(n, p):
  if n == 0:
    return 0
  else:
    return n // p + legendre(n // p, p)

N = int(input())
power_of_prime = [legendre(N, p) for p in prime]

cnt = 1
for i in range(len(power_of_prime)):
  cnt = (cnt * (power_of_prime[i] + 1)) % 1000000007
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
p=10**9+7

def primeryNum(n):
    n_=int(n**0.5)
    ary=list(range(n+1))
    ary[1]=0 
    for a in ary:
        if a>n_: break
        elif a==0: continue
        
        for i in range(a*2,n+1,a):
            ary[i]=0           
    return ary

primeryN=primeryNum(N)

divN=[0]*(N+1)
for pn in primeryN:
    if pn==0:
        continue
    # print(pn)
    i=1
    cnt=0
    while (pn**i<=N):
        cnt+=(N//pn**i)
        i+=1
    divN[pn]=cnt

# print(divN)
ans=1
for d in divN:
    if d==0:
        continue
    ans=(ans*(d+1))%p
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
def p_fact(n):
  m=n
  i=2
  a=[]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a
a=[]
for i in range(1,int(input())+1):
  a+=p_fact(i)
ans=1
mod=10**9+7
for i in list(Counter(a).values()):
  ans*=(i+1)
  ans%=mod
print(ans)

Submission status: Accepted

Solution code:
def bunkai(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

n=int(input())
s=[0]*(n+1)
for i in range(1,n+1):
    fact=bunkai(i)
    for j in fact:
        s[j]+=1
ans=1

for i in range(0,n+1):
    ans*=(s[i]+1)
    ans%=10**9+7

print(ans)

Submission status: Accepted

Solution code:
def factorize(n):
    #https://python.ms/factorize/#%E5%AE%9F%E8%A3%85
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append([b, e])
        b, e = b + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct

n = int(input())

num = 1
for i in range(1,n+1):
    num *= i

fact = factorize(num)
#print(fact)
ans = 1
for i in range(len(fact)):
    ans *= (fact[i][1]+1)

print(ans%(10**9+7))

Submission status: Accepted

Solution code:
import math
import collections
N = int(input())
# N!の約数の個数を10**9+7で割ったあまりを出す
nums = [i for i in range(2, N + 1)]


def prime_factorization(num):
    sqrt_num = math.sqrt(num)
    prime_numbers = []
    for i in range(2, int(sqrt_num) + 1):
        # print(num)
        while num % i == 0:
            # print(num)
            num = num / i
            prime_numbers.append(i)
    if num != 1:
        prime_numbers.append(int(num))

    return prime_numbers


# print(nums)
nums_counter = {}
for num in nums:
    prime_numbers = prime_factorization(num)
    # print(prime_numbers)
    for prime_num in prime_numbers:
        # print(nums_counter)
        # print(prime_num in nums_counter)
        if prime_num in nums_counter:
            nums_counter[prime_num] += 1
        else:
            nums_counter[prime_num] = 1

ans = 1
for key, value in nums_counter.items():
    ans *= (value + 1)
    ans %= 10**9 + 7

print(ans)

Submission status: Accepted

Solution code:
import collections
n = int(input())
t = 1
for i in range(1,n+1):
    t *= i
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(t))
ans = 1
for _, v in c.items():
    ans *= (v + 1)
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
from collections import defaultdict
mod = 10**9+7

def factorize(n):
    out=[]
    i = 2
    while 1:
        if n%i==0:
            out.append(i)
            n //= i
        else:
            i += 1
        if n == 1:break
        if i > int(n**.5+3):
            out.append(n)
            break
    
    return out
  
N=int(input())

if N==1:
  print(1)
  exit()

count = defaultdict(int)
for i in range(2,N+1):
  f = factorize(i)
  for j in range(len(f)):
    count[f[j]] += 1
    
ans = 1
for k in count.keys():
  ans *= count[k]+1 % mod
  
print(ans % mod)

Submission status: Accepted

Solution code:
N = int(input())
p = 10**9+7
T = [0]*(1001)
for m in range(2,N+1):
    pf={}
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    for key in pf.keys():
        T[key] += pf[key]
out = 1
for i in range(1001):
    out = out*(T[i]+1)%p
print(out)

Submission status: Accepted

Solution code:
from math import factorial

n = int(input())
f = factorial(n)

mod = 10 ** 9 + 7

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

ans = 1
for p in primes(n):
    temp = 1
    while f % p == 0:
        temp += 1
        f //= p
    ans = (ans * temp) % mod
print(ans)

Submission status: Accepted

Solution code:
import collections

n = int(input())
mod = 10**9 + 7
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr

tmp = collections.defaultdict(int)

for i in range(1, n+1):
    for j , k in factorization(i):
        tmp[j] += k

ans = 1
for tei, si in tmp.items():
    if tei == 1:
        continue
    else:
        ans *= si + 1
        ans %= mod

print(ans)

Submission status: Accepted

Solution code:
def solve(n):
    l = [1 for i in range(n+1)]
    for k in range(2,n+1):
        tmp = k
        i = 2
        while tmp > 1:
            if tmp % i == 0:
                tmp = tmp // i
                l[i] += 1
            else:
                i += 1
    res = 1
    for i in l:
        res = res * i % (10**9+7)
    return res

if __name__ == '__main__':
    n = int(input())
    print(solve(n))

Submission status: Accepted

Solution code:
s=0
primes=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def warimakuri(N,a,s):
  if N==0:
    return s
  else:
    N=N//a
    s+=N
    return warimakuri(N,a,s)
N=int(input())
mod=1000000007
ans=1
for i in primes:
  if i<=N:
    s=0
    ans=ans*(warimakuri(N,i,s)+1)
    ans=ans%mod
print(ans)

Submission status: Accepted

Solution code:
def factrial(n): # 試し割り算法で素因数分解
  factors = []
  while n%2 == 0:
    factors.append(2)
    n //= 2
    
  for i in range(3, int(n**0.5)+1):
    while n%i == 0:
      factors.append(i)
      n //= i
      
  if n != 1: factors.append(n)
  
  return factors


n = int(input())
mod = 10**9+7

d = {}
for i in range(1, n+1): # 1〜nまでの各値を素因数分解
  fac = factrial(i)
  for j in fac: # 分解して取得した要素の回数をカウント
    if j in d: d[j] += 1
    else: d[j] = 1

ans = 1
for k,v in d.items():
  # 取得した要素に1を足した値を合計値にかけ合わせる
  # 約数として"1"はカウントされていない為、このタイミングで追加する
  ans *= (v+1) 
  ans %= mod
print(ans)

Submission status: Accepted

Solution code:
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):
    result = []
    while n != 1:
        p = prime_table[n]
        e = 0
        while n % p == 0:
            n //= p
            e += 1
        result.append((p, e))
    return result


N = int(input())

m = 1000000007

prime_table = make_prime_table(N)

t = [0] * (N + 1)
for i in range(2, N + 1):
    for p, e in prime_factorize(i):
        t[p] += e

result = 1
for i in range(2, N + 1):
    if t[i] == 0:
        continue
    result = result * (t[i] + 1) % m
print(result)

Submission status: Accepted

Solution code:
n=int(input())
ans=1
rec=[True]*(n+1)
for i in range(2,n+1):
    if rec[i]:
        x=1
        for j in range(1,n+1):
            y=j
            if y%i==0:
                rec[y]=False
            while y%i==0:
                x+=1
                y=y//i
        ans=(ans*x)%1000000007
print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

res = []
result = 1
for I in range(2,N+1):
    res += prime_factorize(I)
for J in set(res):
    result *= res.count(J) + 1
print(result % (10**9+7))

Submission status: Accepted

Solution code:
def factrial(n):
  factors = []
  while n%2 == 0:
    factors.append(2)
    n //= 2
    
  for i in range(3, int(n**0.5)+1, 2):
    while n%i == 0:
      factors.append(i)
      n //= i
      
  if n != 1: factors.append(n)
    
  return factors


n = int(input())
mod = 10**9+7

d = {}
for i in range(1,n+1):
  fac = factrial(i)
  for j in fac:
    if j in d: d[j] += 1
    else: d[j] = 1

ans = 1
for k,v in d.items():
  ans *= (v+1)
  ans %= mod
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
prime_lst = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
lst = [0 for _ in range(n)]
for i in range(1, n + 1):
    a = i
    for num in prime_lst:
        while a % num == 0:
            lst[num - 1] += 1
            a //= num
    if a != 1:
        lst[a - 1] += 1
ans = 1
MOD = 10 ** 9 + 7
for num in lst:
    ans *= (num + 1)
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

arr = [0] * (n+1)

for i in range(1,n+1):
    x = []
    while i % 2 == 0:
        x.append(2)
        i = i // 2
    f = 3
    while f * f <= i:
        if i % f == 0:
            x.append(f)
            i = i // f
        else:
            f += 2
    if i != 1:
        x.append(i)

    for k in range(len(x)):
        arr[x[k]] += 1

ans = 1
for i in range(len(arr)):
    ans *= (arr[i] + 1)
print(ans % (10**9 + 7))

Submission status: Accepted

Solution code:
def factorization(n):
    res = []
    m = 2
    while m ** 2 <= n:
        if n % m == 0:
            cnt = 0
            while n % m == 0:
                cnt += 1
                n //= m
            res.append([m, cnt])
        m += 1

    if n > 1:
        res.append([n, 1])

    return res


n = int(input())

mod = 10 ** 9 + 7

cnt = [0] * (n+1)
for i in range(2, n+1):
    for j, k in factorization(i):
        cnt[j] += k

res = 1
for c in cnt:
    if c > 0:
        res = res * (c + 1) % mod

print(res)

Submission status: Accepted

Solution code:
n=int(input())
temp=[1,1]+[0]*(n-2)
for i in range(3,n+1):
    for j in range(2,i):
        while i%j==0:
            i=i//j
            temp[j-1]+=1
    if i!=1:
      temp[i-1]+=1
ans=1
for i in range(n-1):
    ans=(ans*(temp[i+1]+1))%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
n = int(input())
if n == 1:
  print(1)
  sys.exit()
prime_list = []
    #2からnまでの数字をsearch_listに入れる
search_list = list(range(2,n+1))
while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(n):
        #prime_listにsearch_listを結合
          prime_list.extend(search_list)
          break
      else:
        #search_listの先頭をprime_listに入れる
          head_num = search_list[0]
          prime_list.append(head_num)
        #search_listの先頭をpopする
          search_list.pop(0)
        #head_numの倍数を取り除く
          search_list = [num for num in search_list if num % head_num != 0]
#print(prime_list)
########ここから本問を解く#########
ans = 1
for x in prime_list:
  tmp = 0
  nl = 1
  while(x**nl <= n):
    tmp += n//(x**nl)
    nl += 1
  ans *= tmp+1
if ans >= 10**9+7:
  ans %= (10**9+7)
print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())

facts = [0] * (N + 1)
def f(n):
    i = 2
    while i ** 2 <= N:
        if n % i == 0:
            n //= i
            facts[i] += 1
        else:
            i += 1
    if n > 1:
        facts[n] += 1

for i in range(2, N + 1):
    f(i)
        
ans = 1
for i in range(2, N + 1):
    ans *= facts[i] + 1
    ans %= MOD
print(ans % MOD)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush


n = int(input())
array = [0]*(n+1)

def prime_factor(n):
    for i in range(2, int(n**0.5)+1):
        while n%i == 0:
            array[i] += 1
            n //= i
    if n != 1:
        array[n] += 1

def main():
    for i in range(1, n+1):
        prime_factor(i)
    ans = 1
    for i in range(len(array)):
        ans *= array[i]+1
    print(ans%(10**9+7))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def compute(n):
	prime = [ True for i in range(0, n+1)]
	res = []
	for i in range(2, n+1):
		if prime[i]==True:
			res.append(i)
			for j in range(i , n+1,i):
				prime[j]=False
	return res

mod = 10**9+7
n = int(input())
res = compute(n)
tot = 1
for i in res:
	now = 0
	p =n
	while p>0:
		now = now+(p//i)
		now = now%mod
		p=p//i
	tot = (tot % mod)*((now+1)%mod)
	tot = tot%mod
print(tot)

Submission status: Accepted

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
ans=1
mod=10**9+7
from collections import defaultdict
d=defaultdict(int)
n=int(input())
for i in range(2,n+1):
    lst=factorization(i)
    for a,b in lst:
        d[a]+=b
for v in d.values():
    ans*=(v+1)
    ans%=mod
print(ans)

Submission status: Accepted

Solution code:
import collections

n = int(input())
mod = 10**9+7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

d = collections.defaultdict(int)
for i in range(2,n+1):
    for j in factorization(i):
        d[j[0]] += j[1]

ans = 1
for v in d.values():
    ans *= (v+1)
print(ans%mod)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    N_MAX = N

    min_factor = list(range(N_MAX + 1))
    min_factor[2::2] = [2] * (N_MAX // 2)
    for i in range(3, int(N_MAX ** 0.5) + 2, 2):
        if min_factor[i] != i:
            continue
        for j in range(i * i, N_MAX + 1, 2 * i):
            if min_factor[j] > i:
                min_factor[j] = i

    def prime_factorize_fast(n):
        a = Counter()
        while n != 1:
            a[min_factor[n]] += 1
            n //= min_factor[n]

        return a

    factors = Counter()

    for n in range(2, N + 1):
        factors += prime_factorize_fast(n)

    ans = 1
    for v in factors.values():
        ans = ans * (v + 1) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
n=int(input())
ans=1
dic={}
for i in range(2,n+1):
    tmp=i
    for j in range(2,i+1):
        while tmp%j==0:
            tmp//=j
            if j in dic:
                dic[j]+=1
            else:
                dic[j]=1
for v in dic.values():
    ans=(ans*(v+1))%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())

def factrize(N):
    L={}
    for n in range(2,N+1):
        L[n]=0
        while N % n == 0:
            L[n]+=1
            N = N/n
    return L

f_ = {}
for n in range(2,int(N)+1):
    f_[n]=0
        
for n in range(1,N+1):
    F=factrize(n)
    for f in F.keys():
        f_[f]+=F[f]
        
ans=1
for f in f_.keys():
    if f_[f] != 0:
        ans=ans*(f_[f]+1)
        
print(ans%((10**9)+7))

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10 ** 9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def primeFactorization(n, primes):
    ans = []
    temp = n
    for p in primes:
        while temp%p == 0:
            ans.append(p)
            temp //= p
    if temp > 1:
        ans.append(temp)
    return collections.Counter(ans)

def resolve():
    N = I()

    primes = sieve(N)
    cnt = collections.Counter()
    
    for i in range(2, N + 1):
        pf = primeFactorization(i, primes)
        for k, v in pf.items():
            cnt[k] += v

    ans = 1
    for i in cnt.values():
        ans *= (i + 1)
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n = int(input())

# 素因数分解
cf = dict()
for nn in range(1, n+1):
    cf.setdefault(2, 0)
    while nn%2 == 0:
        cf[2] += 1
        nn //= 2

    for f in range(3, int(nn**0.5)+ 1, 2):
        cf.setdefault(f, 0)
        while nn%f == 0:
            cf[f] += 1
            nn //= f
    if nn != 1:
        cf.setdefault(nn, 0)
        cf[nn] += 1

ans = 1
mod = 10**9+7
for v in cf.values():
    ans *= (v+1)
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
m = math.factorial(N)
A = 1000*[1]
ans = 1

for n in range(2,1001):
  while m%n==0:
    m//=n
    A[n]+=1

for a in A:
  ans*=a

print(ans%(10**9+7))

Submission status: Accepted

Solution code:
from collections import deque

p=10**9+7
def primelist(n):
    l=deque([2])
    stack=deque()
    t=1
    for x in range(3,n+1,2):
        flag=0
        for y in tuple(l):
            if x%y==0:
                flag=1
                break
        if flag==0:
            l.append(x)
    return l

def main():
    n=int(input())
    l=primelist(n)
    ans=1
    while l:
        q=l.pop()
        s=0
        c=1
        while n//(q**c):
            s+=n//(q**c)
            c+=1
        ans=ans*(s+1) % p
    print(ans)

main()

Submission status: Accepted

Solution code:
N = int(input())
A = [a for a in range(2, N+1)]
T = 1
while len(A)>0:
  X = A[0]
  T *= sum(N//(X**i) for i in range(1, 11))+1
  A = [a for a in A if a%A[0]]
print(T%(10**9+7))

Submission status: Accepted

Solution code:
import collections
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main():
    dd = collections.defaultdict(int)
    n = int(input())
    MOD = 10**9 + 7

    for i in range(1,n+1):
        k=factorization(i)
        for j in k:
            dd[j[0]]+=j[1]
    res = 1
    for j in dd.keys():
        if(j!=1):
            res *= (dd[j]+1)%MOD
            res%=MOD
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    1 2 3 4 5 6
    """
    N = read_int()
    divisors = [[] for _ in range(N+1)]
    modulo = 10**9+7
    for i in range(2, N+1):
        if len(divisors[i]) == 0: # if prime
            for j in range(i, N+1, i):
                divisors[j].append(i)
    counter = Counter()
    for i in range(1, N+1):
        j = 0
        temp = i
        while temp != 1 and j < len(divisors[i]):
            if temp%divisors[i][j] == 0:
                counter[divisors[i][j]] += 1
                temp //= divisors[i][j]
            else:
                j += 1
    answer = 1
    for v in counter.values():
        answer = (answer*(v+1))%modulo
    return answer


if __name__ == '__main__':
    print(solve())