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:
class Sieve:
    # Sieve of Eratosthenes
    def __init__(self, n):
        f = [0]*(n+1)
        primes = list()
        f[0] = f[1] = -1
        for i in range(2,n+1):
            if f[i]:
                continue
            primes.append(i)
            f[i]=i
            for j in range(i*i, n+1, i):
                if not f[j]:
                    f[j] = i
        self.f = f
        self.primes = primes
    def isPrime(self, x):
        return self.f[x] == x
    def factorList(self, x):
        res = list()
        while x > 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res
    def factor(self, x):
        fl = self.factorList(x)
        if len(fl) == 0:
            return list()
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res

sv= Sieve(10000)

n=int(input())
ans=1
d=dict()
for i in range(2,n+1):
    f=sv.factor(i)

    for p,cnt in f:
        try:
            d[p]+=cnt
        except:
            d[p]=cnt

for p,cnt in d.items():
    ans*=(cnt+1)
    ans%=(10**9+7)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
count = {}
for i in range(2,N+1):
    f = 2
    tmp = i
    while f**2<=tmp:
        if tmp%f == 0:
            if f not in count:
                count[f] = 0
            count[f] += 1
            tmp //= f
        else:
            f += 1
    if tmp != 1:
        if tmp not in count:
            count[tmp] = 0
        count[tmp] += 1
ans = 1
for v in count.values():
    ans *= (v+1)

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

Submission status: Accepted

Solution code:
n=int(input())

mod=10**9+7

def prime_fact(x):
    fact=[]
    for i in range(2, int(x**(0.5))+1):
        while x%i==0:
            fact.append(i)
            x//=i
    if x!=1:
        fact.append(x)
    if not fact:
        fact=[x]
    return fact

def eratosthenes(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]]

era=eratosthenes(n)
d={}
for key in era:
    d[key]=0

for i in range(2,n+1):
    prime_list=prime_fact(i)
    for prime in prime_list:
        d[prime]+=1

ans=1
for key in d:
    ans*=(d[key]+1)%mod

print(ans%mod)

Submission status: Accepted

Solution code:
from collections import defaultdict

def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())

if N <= 2:
    print(N)
    exit()
else:
    num = defaultdict(int)
    for i in range(2,N+1):
        for n,m in prime_factorize(i):
            num[n] += m


ans = 1
mod = int(1e9+7)
for i in num.values():
    ans = ((i+1)*ans)%mod

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

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

  return res

N = int(input())
factors = defaultdict(int)
factors[1] = 1
for i in range(2, N+1):
  f = factorization(i)
  for d,cnt in f:
    factors[d] += cnt

mod = 10**9+7
res = 1
for i in range(2, N+1):
  res *= (factors[i]+1)
  res %= mod

print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    import math
    class Eratos:
        def __init__(self, num):
            '''
            O(nlglgn) で num までの素数判定テーブルを作る
            >>> e = Eratos(10)
            >>> e.table
            [False, False, True, True, False, True, False, True, False, False, False]
            '''
            assert(num >= 1)
            self.table_max = num
            # self.table[i] は i が素数かどうかを示す (bool)
            self.table = [False if i == 0 or i == 1 else True for i in range(num+1)]
            for i in range(2, int(math.sqrt(num)) + 1):
                if self.table[i]:
                    for j in range(i ** 2, num + 1, i):    # i**2 からスタートすることで定数倍高速化できる
                        self.table[j] = False
        
        def is_prime(self, num):
            '''
            O(1) で素数判定を行う
            >>> e = Eratos(100)
            >>> [i for i in range(1, 101) if e.is_prime(i)]
            [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]
            '''
            assert(num >= 1)
            if num > self.table_max:
                raise ValueError('Eratos.is_prime(): exceed table_max({}). got {}'.format(self.table_max, num))
            return self.table[num]
        
        def prime_factorize(self, num):
            '''
            O(√n) で素因数分解を行う
            >>> e = Eratos(10000)
            >>> e.prime_factorize(6552)
            {2: 3, 3: 2, 7: 1, 13: 1}
            '''
            assert(num >= 1)
            if int(math.sqrt(num)) > self.table_max:
                raise ValueError('Eratos.prime_factorize(): exceed prime table size. got {}'.format(num))
            # 素因数分解の結果を記録する辞書        
            factorized_dict = dict()
            candidate_prime_numbers = [i for i in range(2, int(math.sqrt(num)) + 1) if self.is_prime(i)]
            # n について、√n 以下の素数で割り続けると最後には 1 or 素数となる
            # 背理法を考えれば自明 (残された数が √n より上の素数の積であると仮定。これは自明に n を超えるため矛盾)
            for p in candidate_prime_numbers:
                if num == 1:    # これ以上調査は無意味
                    break
                if num % p == 0:
                    cnt = 0
                    while num % p == 0:
                        num //= p
                        cnt += 1
                    factorized_dict[p] = cnt
            if num != 1:
                factorized_dict[num] = 1
            return factorized_dict
        
        def enum_divisor(self, num):
            '''
            O(√n) で約数列挙を行う
            >>> e = Eratos(10000)
            >>> e.enum_divisor(4)
            [1, 2, 4]
            >>> e.enum_divisor(19)
            [1, 19]
            >>> e.enum_divisor(100)
            [1, 2, 4, 5, 10, 20, 25, 50, 100]
            '''
            divisor_small = []
            divisor_large = []
            for i in range(1, int(math.sqrt(num)) + 1):
                if num % i == 0:
                    divisor_small.append(i)
                    if i != num // i:
                        divisor_large.append(num // i)
            divisor_large.reverse()
            return divisor_small + divisor_large
    
    n = ii()
    eratos = Eratos(n)
    if n == 1:
        print(1)
    else:
        c = Counter()
        for i in range(2, n+1):
            d = eratos.prime_factorize(i)
            c += Counter(d)
        ans = 1
        for k, v in c.items():
            ans = (ans * (v + 1)) % mod
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

N = int(input())
N = math.factorial(N) 

i = 2 
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N = N // i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)

Submission status: Accepted

Solution code:
prime_list = [2]
N = int(input())
A = [0] * N

for i in range(3,10**3+1):
  flag = True
  for j in range(2,int(i**0.5)+1):
    if i % j == 0:
      flag = False
      break
  if flag:
    prime_list.append(i)

for i in range(1,N+1):
  # 素因数分解してAにぶち込む
  tmpN = i
  for j in prime_list:
    while tmpN % j == 0:
      A[j-1] += 1
      tmpN //= j
ans = 1
p = 10**9 + 7
for i in range(1,N):
  ans *= (A[i] + 1)
  ans %= p
print(ans)

Submission status: Accepted

Solution code:
from math import factorial

N = int(input())
N = factorial(N)

i = 2
num = 1
ans = 1

while N != 1:
    if N % i == 0:
        N //= i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10**9) + 7

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
mod = 10 ** 9 + 7

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

primes = []
for i in range(1, N + 1):
    primes += prime_factorize(i)

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

Submission status: Accepted

Solution code:
import math
n = int(input())
mod = 10**9+7

def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

p = []
for i in range(1,n+1):
	if is_prime(i):
		p.append(i)
ans = 1
for i in p:
	s = 0
	x = i
	while x <= n:
		s += n//x
		x *= i
	ans *= (s+1)
	ans %= mod
print (ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
MOD=10**9+7
N=int(input())

def factorize(M):
  fact=defaultdict(int)
  for i in range(2,int(M**0.5)+1):
    if M==1:
      break
    while(M%i==0):
      M//=i
      fact[i]+=1
  
  if M!=1:
    fact[M]=1
  return fact

pdic=defaultdict(int)
for i in range(2,N+1):
  fact=factorize(i)
  for k,v in fact.items():
    pdic[k]+=v
#print(pdic)

answer=1
for v in pdic.values():
  answer*=(v+1)
  answer%=MOD
  
print(answer)

Submission status: Accepted

Solution code:
from collections import defaultdict
factors = defaultdict(int)
N = int(input())
for i in range(2,N+1):
    target = i
    d = 2
    while d**2 <=target:
        if target % d == 0:
            factors[d] += 1
            target //= d
        else:
            d += 1

    if target != 1:
        factors[target] += 1
ans = 1
for v in factors.values():
    ans *= (v+1)
mod = 10**9 +7
print(ans%mod)

Submission status: Accepted

Solution code:

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

class Mint:
    
    MOD = 10**9+7
    
    def __init__(self, x=0):
        self.x = (x%self.MOD + self.MOD) % self.MOD
    
    def __iadd__(self, other):
        self.x += other.x
        if self.x >= self.MOD:
            self.x -= self.MOD
        return self
    
    def __isub__(self, other):
        self.x += self.MOD - other.x
        if (self.x >= self.MOD):
            self.x -= self.MOD
        return self
    
    def __imul__(self, other):
        self.x *= other.x
        self.x %= self.MOD;
        return self;
    
    def __add__(self, other):
        ans = Mint(self.x)
        ans += other
        return ans
        
    def __sub__(self, other):
        ans = Mint(self.x)
        ans -= other
        return ans
    
    def __mul__(self, other):
        ans = Mint(self.x)
        ans *= other
        return ans
    
    def __pow__(self, n):
        if n == 0:
            return Mint(1)
        a = self.__pow__(n >> 1)
        a *= a
        if n&1:
            a *= self
        return a
    
    def inv(self):
        return self**(self.MOD-2)
    
    def __ifloordiv__(self, other):
        self *= other.inv()
        return self
    
    def __floordiv__(self, other):
        ans = Mint(self.x)
        ans //= other
        return ans
        

N = int(input())
from collections import Counter

def Main(N):
    if N == 1:
        return 1
    ans = []
    for i in range(2, N+1):
        ans += prime_factorize(i)
    counter = Counter(ans)
    val = [v+1 for v in counter.values()]
    a = Mint(1)
    for v in val:
        a *= Mint(v)
    return a.x
          
                    
print(Main(N))

Submission status: Accepted

Solution code:
from collections import defaultdict
from functools import reduce
from math import sqrt
def factorint(n):
    d = {}
    for i in range(2, int(sqrt(n))+1):
        c = 0
        q, r = divmod(n, i)
        while not r:
            c += 1
            n = q
            q, r = divmod(n, i)
        if c:
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n = int(input())
mod = 10**9 + 7
A = defaultdict(lambda:1)
for i in range(1, n+1):
    for k, v in factorint(i).items():
        A[k] += v

print(reduce(lambda x, y: x*y % mod, A.values()) if A else 1)

Submission status: Accepted

Solution code:
from collections import defaultdict
from functools import reduce
from math import sqrt
def factorint(n):
    d = dict()
    for i in range(2, int(sqrt(n))+1):
        q, r = divmod(n, i)
        if r == 0:
            c = 0
            while r == 0:
                n = q
                c += 1
                q, r = divmod(n, i)
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n = int(input())
mod = 10**9 + 7
A = defaultdict(lambda:1)
for i in range(1, n+1):
    for k, v in factorint(i).items():
        A[k] += v

print(reduce(lambda x, y: x*y % mod, A.values()) if A else 1)

Submission status: Accepted

Solution code:
def main():
    from math import factorial
    n = int(input())
    mod = 10 ** 9 + 7
    nf = factorial(n)
    l = f(nf)
    ans = 1
    for x in l:
        ans *= (x + 1)
    ans %= mod
    print(ans)


def f(n):
    l = []
    for i in range(2, n + 1):
        if n == 1:
            break
        count = 0
        while n % i == 0:
            n = n // i
            count += 1
        if count > 0:
            l.append(count)
    return l


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#import math
#from decimal import Decimal
import numpy as np
# nの約数を全て求める
# n!が大きすぎ＞　解説をみると。。
# ex; 24 = 2^3 * 3
#       (1,2,3,4,6,8,12,24) > 8個

# approach, 1~Nごとに、素因数分解をして、カウントする。
# 最後に掛け合わせる。
lim = 10 ** 9 + 7
n = int(input())
# https://note.nkmk.me/python-prime-factorization/

num = [0] * (n + 1)
#num[1] = 1

for i in range(2, n + 1):
    temp = i
    # even number
    while (temp % 2 == 0):
        if (num[2] == 0):
            num[2] = 1
        num[2] += 1
        # print('2A')
        temp //= 2

    f = 3
    # odd number
    while (f * f <= temp):
        if (temp % f == 0):
            if (num[f] == 0):
                num[f] = 1
            num[f] += 1
            #print('B', f)
            temp //= f
        else:
            f += 2
    # prime number
    if (temp != 1):
        if (num[temp] == 0):
            num[temp] += 1
        num[temp] += 1
        #print('C', temp)

numA = np.array(num)
numAA = np.argwhere(numA != 0)
numAAA = numAA.tolist()
# print(numA)

ans = 1
for i in numAAA:
    tar = i[0]
    ans *= num[tar]

#ans = sum(num)
ans %= lim

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
arr = [1]*(n+1)
mod = 10**9+7
def factorization(n):
    global 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[i] += cnt%mod

    if temp!=1:
        arr[temp] += 1
        arr[temp] %= mod

    if arr==[]:
        arr[n] += 1
        arr[n] %= mod


for i in range(1,n+1):
    factorization(i)

#print(arr)

anslist = [0]*(n+1)
anslist[1] = arr[1]%mod
for i in range(2,n+1):
    anslist[i] = anslist[i-1]*arr[i]
print(anslist[n]%mod)

Submission status: Accepted

Solution code:
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2,int(n**0.5)+1):
        if i%2==0 and i!=2: continue
        while num%i == 0: num //= i ; ans.append(i)
    if num != 1: ans.append(num)
    return ans

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

primes = []
for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)
ans = 1
for key,val in cnt.items(): ans *= (val + 1) ; ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2,n+1):
        if i%2==0 and i!=2: continue
        while num%i == 0: num //= i ; ans.append(i)
    return ans

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

primes = []
for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)
ans = 1
for key,val in cnt.items(): ans *= (val + 1) ; ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2,n+1):
        if i%2==0 and i!=2: continue
        while num%i == 0: num //= i ; ans.append(i)
    return ans

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

primes = []
for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)
ans = 1
for key,val in cnt.items(): ans *= (val + 1)
print(ans%mod)

Submission status: Accepted

Solution code:
N = int(input())
# 素数の登場回数を記録する
ps = [0] * (N+1)

for i in range(2,N+1):
  x = i
  p = 2
  while x > 1 :
    while x % p == 0:
      ps[p] += 1
      x //= p
    p += 1
ans = 1
for c in ps:
  ans = (ans * (c+1)) % 1000000007
print(ans)

Submission status: Accepted

Solution code:
#素因数分解
#factorization(2016)=[[2, 5], [3, 2], [7, 1]]の形で出力
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

n=int(input())
p=10**9+7
fli=[1]*(n+1)
for i in range(2,n+1):
  f=factorization(i)
  for j in range(len(f)):
    fli[f[j][0]]+=f[j][1]
ans=1
for i in range(n+1):
  ans=ans*fli[i]%p
print(ans)

Submission status: Accepted

Solution code:
import collections
N = int(input())
num = []
mod = 10**9+7
for i in range(2,N+1):
    for j in range(2,i+1):
        #print(j)
        while i%j==0:
            i //= j
            num.append(j)
#print(num)
A = collections.Counter(num)
#print(A)
ans = 1
for v in A.values():
    ans *= (v+1)%mod
print(ans%mod)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
l=[]
for i in range(2,n+1):
    k=2
    t=i
    while k*k<=t:
        if t%k==0:
            l.append(k)
            t=t//k
        else:k+=1
    if n>0:l.append(t)

c=Counter(l)
ans=1
for key,value in c.items():
    ans*=value+1
print(ans%(10**9+7))

Submission status: Accepted

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

primes = [0]*(n+1)
for i in range(1,n+1):
    for num,cnt in factorize(i):
        if num==1:continue
        primes[num] +=cnt
ans = 1
mod = 10**9+7
for cnt in primes:
    ans = ans*(cnt+1)%mod
print(ans)

Submission status: Accepted

Solution code:
import math
from collections import defaultdict

N = int(input())
mod = 10 ** 9 + 7
ans = 1
# それぞれの因数となる素数の数をセットする
dp = [0] * (N + 1)
# 素因数分解する関数
def prime_factorize(n):
    divisors = []
    # 27(2 * 2 * 7)の7を出すためにtemp使う
    temp = n
    for i in range(2, int(math.sqrt(n)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                # 素因数を見つけるたびにtempを割っていく
                temp //= i
            divisors.append([i, cnt])
    if temp != 1:
        divisors.append([temp, 1])
    if divisors == []:
        divisors.append([n, 1])

    return divisors

for i in range(1, N + 1):
    for j in prime_factorize(i):
        if j[0] > 1:
            dp[j[0]] += j[1]
# 約数の数:それぞれの因数の(因数の数 + 1)を掛け合わせたもの
for i in dp:
    if i > 0:
        ans = (ans * (i + 1)) % mod
print(ans % mod)

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

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

n = int(input())
a = 1
ans = 0
for i in range(1,n+1):
    a *= i
c = prime_factorize(a)
d = collections.Counter(c)
ans = 1
for value in d.values():
    ans *= (value+1)
    ans %= MOD
print(ans)

Submission status: Accepted

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

def prime_decomposition(n):
    i = 2
    tank = []
    while i * i <= n:
        while n%i == 0:
            n /= i
            tank.append(i)
        i += 1
    if n > 1:
        tank.append(int(n))
    return tank

dic = {i:0 for i in range(n+1)}
for i in range(2, n+1):
    l = prime_decomposition(i)
    for x in l:
        dic[x] += 1
ans = 1
for k,v in dic.items():
    if v!=0:
        ans *= (v+1)
        ans %= mod
print(ans%mod)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
MOD = 10**9 + 7


def f(v):
    a = 2
    dic = defaultdict(int)
    while v != 1:
        if v % a == 0:
            dic[a] += 1
            v //= a
        else:
            a += 1
    return dic


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

dic = defaultdict(int)
for i in range(2, N + 1):
    d = f(i)
    for key, value in d.items():
        dic[key] += value

# print('dic', dic)
ans = 1
for value in dic.values():
    ans *= value + 1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
import functools
def primes(n):

    prime_list = list(range(n+1))
    prime_list[1] = 0
    for i in range(2, int(n)+1):
        if prime_list[i] != 0:
            for j in range(2*i, n+1, i):
                prime_list[j] = 0

    return [i for i in prime_list if i != 0]

def solve(n):

    prime_list = primes(n)
    powers = []
    for p in prime_list:
        tmp = 0
        a = p
        while a <= n:
            tmp += n // a
            a *= p
        powers.append(tmp)

    ans = functools.reduce(
        lambda acc, x: (acc*(x+1)) % (10**9+7), powers, 1)

    return ans

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

Submission status: Accepted

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

nn = math.factorial(n)

if n ==1:
    print(1)
    
elif n ==2:
    print(2)
else:
    sosu =[2]  
   
    for i in range(3,n+1,2):
        judge = 0
        for j in range(2,i):
            if i % j == 0:
                judge = 1
        if judge ==0:
            sosu.append(i)
    
    slist =[0]*len(sosu)
    for k in range(0,len(sosu)):
        m = nn
        count = 0
        while m % sosu[k] ==0:
            m = m //sosu[k]
            count +=1
        slist[k] = count
    
    res = 1
    for l in range(0,len(slist)):
        res =res*(slist[l]+1) % 1000000007

    print(res)

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

MOD=10**9+7

n=int(input())
li=[0]*2000

for i in range(1,n+1):
    c=factorization(i)
    #print(c)
    for j in range(len(c)):
        li[c[j][0]]+=c[j][1]

ans=1

for i in range(2,n+1):
    ans=ans*(li[i]+1)
    ans=ans%MOD

print(ans)

Submission status: Accepted

Solution code:
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

n=int(input())
dat = [0] * 2000 

res = 1
for i in range(1, n + 1):
    d = factorization(i)
    #print(d)
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]

#print(dat)

for i in range(2, n + 1):
    res *= (dat[i] + 1)
    res %= mod

print(res)

Submission status: Accepted

Solution code:
n = int(input())
num = [0]*(n+1)
ans = 1
for i in range(2,n+1):
    j=2
    while j<n+1 and i>1:
        if i%j==0:
            i=i//j
            num[j]+=1
        else:
            j+=1
for i in num:
    ans=ans*(i+1)%1000000007
print(ans)

Submission status: Accepted

Solution code:
import math

N = int(input())

dic = {}
for n in range(2, N + 1):
    p = 2
    while 1 < n and p <= math.sqrt(n):
        if n % p == 0:
            while n % p == 0:
                n //= p
                dic[p] = dic.get(p, 0) + 1
        p += 1

    if n > 1:
        if n not in dic:
            dic[n] = 1
        else:
            dic[n] += 1

ret = 1
for v in dic.values():
    ret *= v + 1

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 10 ** 9 + 7

def factorize(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

def main():
    N = int(readline())
    factors = []
    for i in range(1, N+1):
        factors += factorize(i)
    c = Counter(factors)
    ans = 1
    for key, val in c.items():
        if key == 1:
            continue
        ans *= (val + 1)
        ans %= MOD
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    d = {}
    for i in range(2, N+1):
        for j in prime_factors(i):
            d[j] = d[j] + 1 if j in d else 1
    res = 1
    for v in d.values():
        res *= (v+1)
    print(res%(10**9+7))

def prime_factors(n):
    i = 2
    factors = []
    while i**2 <= n:
        if n % i != 0:
            i += 1
        else:
            factors.append(i)
            n = n // i
    if n > 1:
        factors.append(n)
    return factors

if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print(1)
    exit()
# calculate primes by sieve
primes = list(range(2, N + 1))
prime_index = 0
n = primes[prime_index]
while n**2 <= N:
    primes = list(filter(lambda x: x == n or x % n != 0, primes))
    prime_index += 1
    n = primes[prime_index]
# calculate exponents
exponents = [0 for _ in range(len(primes))]
for n in range(2, N + 1):
    for prime_index, prime in enumerate(primes):
        exponent = 0
        tmp = n
        while tmp % prime == 0:
            tmp //= prime
            exponent += 1
        exponents[prime_index] += exponent
# calculate answer
const = 10**9 + 7
answer = 1
for e in exponents:
    answer = answer * (e + 1)
    answer %= const
print(answer)