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 collections import Counter
M = 10**9 + 7
N = int(input())

prime = [True] * (N+1)
prime[0] = False
prime[1] = False
for i in range(4, N+1, 2):
    prime[i] = False
for i in range(3, N+1, 2):
    if prime[i]:
        for j in range(2*i, N+1, i):
            prime[j] = False

primes = [i for i, b in enumerate(prime) if b]

def fact(k, pdict):
    a = k
    for p in primes:
        if p*p > k:
            break
        c = 0
        while a % p == 0:
            a //= p
            c += 1
        pdict[p] += c
    if a > 1:
        pdict[a] += 1

def solve():
    pdict = Counter()
    for k in range(2, N+1):
        fact(k, pdict)

    ans = 1
    for v in pdict.values():
        ans = ans * (v+1) % M
    return ans


print(solve())

Submission status: Accepted

Solution code:
N = int(input())
mod = pow(10, 9) + 7
A = [0]*(N+1)
for i in range(2, N+1):
  for j in range(2, N+1):
    while i % j == 0:
      i //= j
      A[j] += 1
ans = 1
for i in range(len(A)):
  if A[i] != 0:
    ans *= A[i] + 1
print(ans % mod)

Submission status: Accepted

Solution code:
N = int(input())
mod = pow(10,9)+7
A = [1]*(N+1)
for i in range(1,N+1):
    n = i
    for j in range(2,i+1):
        if j>n:break
        while n%j==0:
            A[j]+=1
            n//=j
cnt = 1
for i in range(N+1):
    cnt *= A[i]
print(cnt%mod)

Submission status: Accepted

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


N = int(input())
MOD = 10**9 + 7
fact = [[0, 0]]

for i in range(2, N+1):
    for fi in factorization(i):
        primes = [f[0] for f in fact]
        if fi[0] in primes:
            ind = primes.index(fi[0])
            fact[ind][1] += fi[1]
        else:
            fact.append(fi)

ans = 1
for f in fact:
    ans *= (f[1] + 1)
    ans %= MOD

print(ans)

Submission status: Accepted

Solution code:
def prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for j in range(4, n+1, 2):
        is_prime[j] = False
    for i in range(3, int(n**0.5) + 1, 2):
        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]]

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

n = int(input())
prime_list = prime(n)
p = len(prime_list)
key = dict()
for value in prime_list:
    key[value] = 0
for i in range(1, n+1):
    div = make_divisors(i)
    for d in div:
        if d in key:
            k = 0
            i_c = i
            while i_c%d == 0:
                k += 1
                i_c //= d
            key[d] += k
ans = 1
for v in key.values():
    ans *= v+1
    ans %= 10**9+7
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
fct = [1]*(n+7)
for i in range(2,int(n**(1/2))+7):
    if fct[i]:
        for j in range(2*i,n+1,i):
            fct[j]=0
fct2 = {i:1 for i in range(2,n+1) if fct[i]}
fct3 = [i for i in range(2,n+1) if fct[i]]
for i in range(2,n+1):
    for j in fct3:
        i2 = i
        while i2%j==0:
            fct2[j]+=1
            i2//=j
mod = 10**9+7
ans = 1 
for i in fct2:
    ans*=fct2[i]
    ans%=mod
            
print(ans)

Submission status: Accepted

Solution code:
import math

N =int(input())
r = 10 ** 9 + 7
num_lis = [2]

for i in range(N+1):
    for j in range(2,i):
        if i % j == 0:
            break
        elif j == i - 1:
            num_lis.append(i)

num_lis2 = [0] * len(num_lis)

tmp1 = 1
tmp2 = 0
for i in range(len(num_lis)):
    count = 0
    tmp1 = 1
    tmp2 = num_lis[i]
    while tmp2 ** tmp1 <= N:
        tmp3 = tmp2 ** tmp1
        count += int(math.floor(N / tmp3))
        tmp1 += 1
    num_lis2[i] = count

Ans = 1
for i in range(len(num_lis2)):
    Ans = Ans * (num_lis2[i] + 1)
    Ans = Ans % r

print(Ans)

Submission status: Accepted

Solution code:
from math import log
N=int(input())
lp=[1 for i in range(N+1)]#ind=suuzi
for i in range(2,N+1):
    if lp[i]==1:
        for j in range(2*i,N+1,i):
            lp[j]=0
ans=1
MOD=10**9+7
for i in range(2,N+1):
    if lp[i]==1:
        count=0
        for j in range(int(log(N,i))):
            count=(count+N//(i**(j+1))%MOD)%MOD
        ans=ans*(count+1)%MOD
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):
    p = prime_factorize(i)
    primes.extend(p)
c = Counter(primes)

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

Submission status: Accepted

Solution code:
# import bisect
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
#import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def prime_factorize1(N):
        """
        Nをくって、Nの素因数を格納したリストresを返す。
        リストの要素をすべて掛ければNになる"""
        res = []
        x = N
        y = 2
        while y*y <= x:
            while x % y == 0:
                res.append(y)
                x //= y
            y += 1
        if x > 1:
            res.append(x)
        return res

    n=int(input())
    mod=10**9+7
    ans=[]
    for i in range(1,n+1):
        ans.extend(prime_factorize1(i))
    ans=Counter(ans)
    cnt=1
    for j in ans.values():
        cnt*=(j+1)
    print(cnt%mod)





resolve()

Submission status: Accepted

Solution code:
import math
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

mod = 10 ** 9 + 7
ans = 0
def eratos(num):
    dp = [True] * (num)
    dp[0] = dp[1] = False # 0, 1をFalseに
    sqrt_num = int(num ** 0.5) + 1
    for i in range(2, sqrt_num):
        if dp[i]:
            for j in range(i**2, num, i):
                dp[j] = False
    primes = []
    for index, k in enumerate(dp):
        if k:
            primes.append(index)
    return primes
primes = eratos(n + 1)

m = []
for p in primes:
    t = 0
    for i in range(1, n + 1):
        while i % p == 0:
            t += 1
            i //= p
    m.append(t)
ans = 1
for k in m:
    ans *= (k + 1) % mod
print(ans % mod)

Submission status: Accepted

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

def primenumber_table(N):  # N以下の素数テーブル エラトステネスの篩
  table=[i for i in range(2,N+1)]
  l=[]
  while len(table)!=0:
    num=table[0]
    l.append(num)
    i=0
    while i<len(table):
      if table[i]%num==0:
        table.pop(i)
      else:
        i+=1
  return l
    
table=primenumber_table(1000)
v=math.factorial(n)
init_v=v
while v!=1:
  for num in table:
    cnt=0
    while v%num==0:
      cnt+=1
      v//=num
    if cnt!=0:
      ans*=(cnt+1)
      ans%=mod
  if v==init_v:
    ans*=2
    ans%=mod
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
#nを因数分解する
#arr = [素因数,個数] のリスト
#n==1 のとき [1,1] となるので注意
arr = []

def factorization(n):
    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

for i in range(2,N+1):
    factorization(i)

result = []
for i in range(2,N+1):
    c = 0
    for j in range(len(arr)):
        if i == arr[j][0]:
            c += arr[j][1]
    if c > 0:
        result.append([i,c])

ans = 1
for i in range(len(result)):
    ans *= result[i][1]+1
    ans %= 1000000007

print(ans)

Submission status: Accepted

Solution code:
mod = 10**9+7
N = int(input())
prime = [2]
for i in range(3,N+1):
    flag = True
    for x in prime:
        if i%x == 0:
            flag = False
    if flag:
        prime.append(i)
ans = 1
for p in prime:
    e = 1
    cnt = 0
    while p**e <= N:
        cnt += N//(p**e)
        e += 1
    ans = ans *(cnt+1)%mod
print(ans)

Submission status: Accepted

Solution code:
#ARC067-C
N=int(input())
CNT=[0 for i in range(N+1)]
for i in range(2,N+1):
    k=2
    while k<=i:
        if i%k==0:
            CNT[k]+=1
            i//=k
        else:
            k+=1
ans=1
for cnt in CNT:
    ans*=cnt+1
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())

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

d = {}
for i in range(2, n + 1):
    t = prime_division(i)
    for j in t:
        if j[0] in d:
            d[j[0]] += j[1]
        else:
            d[j[0]] = j[1]

num = 1
for i in d.values():
    num *= i + 1

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

Submission status: Accepted

Solution code:
N = int(raw_input())

dist = [0]*(N+1)
mod = 10**9 + 7
dist[1] = 1

for i in range(1,N+1):
    for j in range(2,i+1):
        while i%j == 0:
            dist[j] += 1
            i = i/j
ans = 1
for i in range(2, N+1):
    if dist[i] != 0:
        ans = ans*(dist[i]+1)%mod

print ans

Submission status: Accepted

Solution code:
import math

N = int(input())
n = int(math.sqrt(N))
fact = [0] * (N + 1)
MOD = 10 ** 9 + 7

for i in range(2, N + 1):
    tmp = i
    for j in range(2, n + 1):
        if tmp % j == 0:
            while tmp % j == 0:
                fact[j] += 1
                tmp = tmp // j

    if tmp != 1:
        fact[tmp] += 1
ans = 1
for f in fact[1:]:
    ans *= f + 1
    ans %= MOD

print(ans)

Submission status: Accepted

Solution code:
def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

def D(n,d):
  c=0
  while n>0:
    c=c+n//d
    n=n//d
  return c

A=primes(1000)
P=[[0]*2 for i in range(len(A))]
for i in range(len(A)):
  P[i][0]=A[i]
n=int(input())
mod=10**9+7
for j in range(len(A)):
  P[j][1]=P[j][1]+D(n,A[j])
ans=1
for i in range(len(A)):
  ans=ans*(P[i][1]+1)%mod
print(ans)

Submission status: Accepted

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


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


d = defaultdict(int)
for i in range(1, n+1):
    f = factorization(i)
    for k, v in f:
        d[k] += v

ans = 1

for k, v in d.items():
    if k == 1:
        continue
    ans = ans*(v+1) % MOD

print(ans)

Submission status: Accepted

Solution code:
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)

from collections import defaultdict

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 = ii()
d = defaultdict(int)
for i in range(2, N+1):
    for l in factorization(i):
        d[l[0]] += l[1]
#print(d)
ans = 1
INF = 10**9+7

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

ans = ans%INF
          
print(ans)

Submission status: Accepted

Solution code:
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)

from collections import defaultdict

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 = ii()
d = defaultdict(int)
for i in range(2, N+1):
    for l in factorization(i):
        d[l[0]] += l[1]
#print(d)
ans = 1
INF = 10**9+7

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

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, accumulate
import itertools
import heapq
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

def factorization(n):
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret

def main():
    N = I()
    v = defaultdict(int)

    for i in range(1, N+1):
        fac = factorization(i)
        for f in fac:
            v[f] += 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
MOD = 10**9 + 7
N = int(input())
P = []
for M in range(2,N+1):
    Q = []
    k = 2
    while k*k <= M:
        if M%k == 0:
            M //= k
            Q.append(k)
        else:
            k += 1
    if M > 1:
        Q.append(M)
    P += Q

C = Counter(P)
ans = 1
for e in C:
    ans *= C[e]+1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
import math

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

ans = 1
i = 2
while i <= x:
    cnt = 1
    while x%i == 0:
        x //= i
        cnt += 1
    ans *= cnt
    i += 1
                
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
MOD = 1000000007

n = int(input())

cnt = [0 for _ in range(1010)]
for i in range(1, n + 1):
    j = 2
    while j * j <= i:
        while i % j == 0:
            i //= j
            cnt[j] += 1
        j += 1
    
    if i > 1:
        cnt[i] += 1

ans = 1
for x in cnt:
    ans = ans * (x + 1) % MOD

print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
ans = 1
num_list = [0] * (N + 1)
for n in range(2, N+1):
    for i in range(2, 10 ** 3 + 1):
        while n % i == 0:
            num_list[i] += 1
            n //= i
for i in num_list:
    ans *= (i+1)
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
a = [1]*1001
ans=1
def prime_factorize(n):
    
    while n % 2 == 0:
        a[2]=a[2]+1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f]=a[f]+1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n]=a[n]+1
    return a

for i in range(1,x+1):
	prime_factorize(i)
for i in range(x+1):
	ans=(ans*a[i])%(10**9+7)
print(ans)

Submission status: Accepted

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

prime = {}
for i in range(2, n+1):
    for j in range(2, int(i**0.5)+1):
        if i%j != 0:
            continue

        prime.setdefault(j, 1)

        while i%j == 0:
            i //= j
            prime[j] += 1

    if i != 1:
        if i not in prime:
            prime.setdefault(i, 1)
        else:
            prime[i] += 1

ans = 1
for k, v in prime.items():
    ans *= (v+1)%mod
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


n = int(input())
mod = 10**9 + 7
dic = {}
for i in range(2, n + 1):
    tmp = prime_factorize(i)
    for j in tmp:
        if j in dic:
            dic[j] += 1
        else:
            dic[j] = 1

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

if ans == 1:
    print(1)
else:
    print(ans % mod)

Submission status: Accepted

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

res = 1
ex = [0 for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(2, i + 1):
        if i % j == 0:
            while i % j == 0:
                ex[j] += 1
                i //= j

ans = 1
for i in range(n + 1):
    ans *= (ex[i] + 1)
    ans %= MOD
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
m = pow(10,9)+7

A = [1]*(N+1)
for n in range(2,N+1):
    k = n
    for i in range(2,n+1):
        if k%i==0:
            while k>1:
                k//=i
                A[i]+=1
                if k%i!=0:break
ans = 1
for a in A:ans*=a
print(ans%m)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input().strip())
#-----


class factorization():
    def get_divisor(self, n :int) -> dict:
        divisor_dic={}
        
        tmp_num = n
        for i in range(2,n):
            
            while tmp_num % i == 0:
                divisor_dic.setdefault(i,0)
                divisor_dic[i] += 1
                
                tmp_num //= i
        
        return divisor_dic




divisor_dic={}  # 階乗を素因数分解し、結果を入れる
for num in range(2,N+1):
    # 階乗の、それぞれの数字について、約数を抽出
    fa = factorization()
    ret = fa.get_divisor(num)
    
    if ret == {}:
        divisor_dic.setdefault(num,0)
        divisor_dic[num] += 1
    else:
        for key,v in ret.items():
            divisor_dic.setdefault(key,0)
            divisor_dic[key] += v

cnt=1
for key,v in divisor_dic.items():
    cnt = cnt * (divisor_dic[key] + 1) % (10**9 + 7)

print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin
from collections import defaultdict
mod = 10**9+7
N = int(stdin.readline().rstrip())

def factorize(n):
    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
  
ans = 1
fact = defaultdict(int)
for i in range(2,N+1):
    for j,k in factorize(i):
        fact[j] += k

for l in fact.values():
    ans *= (l+1)
    ans %= mod
print(ans%mod)

Submission status: Accepted

Solution code:
n = int(input())
D = [0]*(n+1)
mod = 10**9+7

for i in range(2, n+1):
  target = i
  for j in range(2, n+1):
    while target%j==0:
      D[j] += 1
      target = target//j

ans = 1

if n==1:
  print(ans)
else:
  for k in range(2, n+1):
    ans = ans*(D[k]+1)%mod
  print(ans)

Submission status: Accepted

Solution code:
n = int(input())
mod = 10**9+7
prime=[]
for i in range(2,n+1):
    for k in range(len(prime)):
        if i % prime[k] == 0:
            break 
    else:
        prime.append(i)
fac = []
for i in range(len(prime)):
    fac.append(0)
for i in range(n+1):
    while i > 1:
        for k in range(len(prime)):
            while i % prime[k] == 0:
                i = i // prime[k]
                fac[k] += 1
count = 1
for i in range(len(fac)):
    count *= fac[i] + 1
    count %= mod
print(count)

Submission status: Accepted

Solution code:
n = int(input())

d = {}
for i in range(2, n+1):
    j = 2
    while i >= j:
        if i % j == 0:
            i //= j
            if d.get(j):
                d[j] += 1
            else:
                d[j] = 1
        else:
            j += 1
            
ans = 1
for k, v in d.items():
    ans *= (v+1)

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

Submission status: Accepted

Solution code:
import numpy as np
from collections import Counter

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

mod = 1000000007
N = int(input())
prime_factors = {}
for i in range(2, N+1):
    counts = Counter(prime_factorization(i))
    for k,v in counts.items():
        prime_factors[k] = prime_factors.get(k, 0) + v
ans = 1
for v in prime_factors.values():
    ans *= (v+1)
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

# def is_prime(n):
#     for i in range(2, n + 1):
#         if i * i > n:
#             break
#         if n % i == 0:
#             return False
#     return n != 1


# A = []
# for i in range(1, x+1):
#     if is_prime(i):
#         A.append(i)
# # print(A)
# B = [0] * 1000
# for i in range(1, x+1):
#     for j in A:
#         if i % j == 0:
#             B[j] += 1
#         for k in range(2, 15):
#             if j**k == i:
#                 B[j] += k -1
#     print(B[2:x])
# t = 1
# for i in B:
#     t *= (i+1)
#     t %= 1000000007
# # print(B)
# print(t)

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

A = [0] * 1000
for i in range(1, x+1):
    B = factorization(i)
    for j in B:
        a, b = j
        A[a] += b

t = 1
for i in A[2:]:
    t *= (i+1)
    t %= 1000000007
print(t)

Submission status: Accepted

Solution code:
N = int(input())
mod = pow(10,9)+7
S = []
A = [True]*(N+1)
A[0] = A[1] = False
for i in range(2,N+1):
    if A[i]:
        S.append(i)
        A[i::i] = [False]*(N//i)
B = [1]*(N+1)
for i in range(2,N+1):
    n = i
    for s in S:
        while n%s==0:
            B[s]+=1
            n//=s
ans = 1
for b in B:ans*=b
print(ans%mod)

Submission status: Accepted

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

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

import math
prime_factors = prime_factorization(math.factorial(n))

from collections import Counter
c = Counter(prime_factors)

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

Submission status: Accepted

Solution code:
def count_divisor(n):
    count = 1
    divisor = 2
    while divisor * divisor <= n:
        degree = 0 # 次数
        while n % divisor == 0:
            n = n // divisor
            degree += 1
        divisor += 1
        count *= (degree + 1)
    if n > 1:
        count *= 2
    return count

def solve():
    n = int(input())
    MOD = 10 ** 9 + 7
    f = 1
    for i in range(1, n+1):
        f *= i
    return count_divisor(f) % MOD

print(solve())

Submission status: Accepted

Solution code:
from functools import lru_cache
from collections import defaultdict
MOD = 10**9 + 7


def Is_prime(n):
    # nが1以下ならFalse
    if n<=1:
        return False
    # nが2または3ならTrue
    if n==2 or n==3:
        return True
    # nが2の倍数ならFalse
    if n%2==0:
        return False
    # nの平方根を整数で取得
    sqrt_root = int(n**.5)
    # nがnの平方根以下の3以上の奇数で1回でも割れたらFalse
    for i in range(3,sqrt_root+1,2):
        if n%i==0:
            return False
    # 上の条件を全てぬけたものはTrue
    return True

# 素数テーブル
# n以下の素数を列挙する
def Prime_table(n):
    res = []
    for i in range(n+1):
        if Is_prime(i):
            res.append(i)
    return res

# 素因数分解
def Factorization(n):
    prime_table = Prime_table(n)
    arr = []
    temp = n
    for i in prime_table:
        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())
L = list(map(Factorization, range(2,N+1)))

d = defaultdict(int)
for i in range(len(L)):
    for l in L[i]:
        d[l[0]] += l[1]

res = 1
for i in d.values():
    res *= (i+1)
    res %= MOD
print(res)

Submission status: Accepted

Solution code:
from collections import Counter

#https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

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())
mod = 10**9+7
counter = Counter()
for n in range(1,N+1):
    fs = factorization(n)
    for f in fs:
        counter[f[0]] += f[1]

counts = counter.most_common()
ans = 1
for count in counts:
    if count[0] != 1:
        ans *= (count[1]+1)
        ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import math
MOD=1000000007
    
def prime(n):
    max=int(math.sqrt(n))
    li=[i for i in range(2,n+1)]
    primes=[]
    while li[0]<=max:
        primes.append(li[0])
        tmp=li[0]
        li=[i for i in li if i%tmp!=0]
    primes.extend(li)
    return primes

sosu=prime(1000)
N=int(input())
Nbeki=1
for i in range(1,N+1):
    Nbeki=Nbeki*i%MOD

soin=[0]*1000

for i in range(1,N+1):
    for j in range(len(sosu)):
        while(i%sosu[j]==0):
            i//=sosu[j]
            soin[sosu[j]]+=1

ans=1
for i in range(len(soin)):
    if(soin[i]!=0):
        ans=ans*(soin[i]+1)%MOD
print(ans)

Submission status: Accepted

Solution code:
def ord(N,n):#N,nは正の整数、Nで割り切れる回数、許容はN^1000
    if n%N!=0:
        return 0
    else:
        return 1+ord(N,n//N)

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

primelist=get_sieve_of_eratosthenes_new(1000)

import sys

input=sys.stdin.readline

N=int(input())

factorize=[0 for i in range(0,len(primelist))]

for i in range(1,N+1):
    for j in range(0,len(primelist)):
        factorize[j]+=ord(primelist[j],i)
        i=i//primelist[j]**ord(primelist[j],i)

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

Submission status: Accepted

Solution code:
import math

N = int(input())

def append_divisor(divisors, num):
    if num not in divisors:
        divisors[num] = 1
    else:
        divisors[num] += 1

def solve(divisors, num):
    limit = int(math.sqrt(num)) + 1
    for i in range(2, limit):
        while num % i == 0:
            append_divisor(divisors, i)
            num //= i
    if num != 1:
        append_divisor(divisors, num)

divisors = {}
for i in range(2, N + 1):
    solve(divisors, i)
# print(divisors)

mod = 10**9 + 7

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