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:
# 素因数分解
def prime_factorization(N):
    tmp = N
    ans = []
    for i in range(2, int(N ** 0.5) + 1):
        count = 0
        while tmp % i == 0:
            tmp //= i
            count += 1
        if count != 0:
            ans.append([i, count])
    if tmp != 1:
        ans.append([tmp, 1])
    if ans == []:
        ans.append([N, 1])
    return ans


mod = 10 ** 9 + 7
N = int(input())
prime_list = [0] * N
if N == 1:
    print(1)
    exit()

for i in range(1, N+1):
    tmp_list = prime_factorization(i)
    ##print(i, tmp_list)
    for k in range(len(tmp_list)):
        prime_list[tmp_list[k][0]-1] += tmp_list[k][1]

ans = 1
for i in range(1, N):
    ans *= prime_list[i] + 1
    ans %= mod
##print(prime_list)
print(ans)

Submission status: Accepted

Solution code:
MOD = 10**9+7
max_n = 1000

n = int(input())

ans = 0
nums = [0]*(n+1)

for i in range(1,n+1):  
  v = i
  j = 2
  while v > 0 and i>=j:    
    if v%j==0:
      nums[j] += 1
      v = v//j      
    else:
      j+=1

ans = 1      
for i in range(n+1):
  if nums[i] > 0:
    ans *= (1+nums[i])
  ans %= MOD

print(ans)

Submission status: Accepted

Solution code:
p = []
for i in range(2, 1000):
  pix = 0
  for j in range(len(p)):
    if i % p[j] == 0:
      pix = 1
  if pix == 0:
    p.append(i)

mod = int(1e+9 + 7)
N = int(input())
D = {i: 0 for i in p}
for i in range(1, N + 1):
  if i in p:
    D[i] += 1
  else:
    for j in p:
      z = 0
      while i % j == 0:
        i //= j
        z += 1
      D[j] += z
prod = 1
for i in D:
  prod *= D[i] + 1
  prod %= mod
print(prod)

Submission status: Accepted

Solution code:
import math
n=int(input())
prime=[]


def expFactor(n, p): 
    x = p 
    exponent = 0
    while n // x > 0: 
      
        exponent += n // x 
        x *= p 
    return exponent 

ans=1

if(n>=2):
    prime.append(2)
for i in range(3,n+1):
    countt=0
    for j in range (1,int(math.sqrt(i))+1):
        if(i%j==0):
            countt+=1
    if(countt==1):
        prime.append(i)
#print(prime)
for i in prime:
    ans*=(expFactor(n,i)+1)
print(ans%(1000000007))

Submission status: Accepted

Solution code:
def prmry_num_li(mx_int = 10**5):
    li = [True for i in range(mx_int+1)]
    li[0] = False
    li[1] = False

    for i in range(2,int(mx_int**0.5)+1):
        if (li[i]):
            j = 2
            while (i*j <= mx_int):
                li[i*j] = False
                j+= 1
    lis = []
    for i in range(len(li)):
        if li[i]:
            lis.append(i)

    return lis


n = int(input())
li = prmry_num_li(n)
cnt = [0 for _ in range(len(li))]

for i in range(1,n+1):
    num = i
    plc = 0
    while(num!=1):
        if num%li[plc]==0:
            num/=li[plc]
            cnt[plc] += 1
        else:
            plc+=1

mod = 10**9+7
ans = 1 
for j in range(len(cnt)):
    ans = (ans*(cnt[j]+1))%mod

print(ans%mod)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0

def primer(x):
    res = []
    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

res_all = []
for i in range(N+1):
    res_all.extend(primer(i))
from collections import Counter
D = Counter(res_all)
ans = 1
for value in D.values():
    ans *= value+1
    ans %= 10**9+7
print(ans)

Submission status: Accepted

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    # 終点はルート切り捨て+1
    for i in range(2, int(sqrt(num))+1):
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

N = INT()

# 素因数分解で全部素数冪にして集計
C = Counter()
for a in range(2, N+1):
    C.update(factorize(a))

# 素数冪から約数の個数を求める
ans = 1
for v in C.values():
    ans *= v + 1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
MOD = 1000000007  # type: int
from collections import Counter

# 素因数分解
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def solve(N: int):
    soinsuu = prime_decomposition(math.factorial(N))
    counter = Counter(soinsuu)
    answer =1
    for value in counter.values():
        answer = answer*(value+1)
        answer%=MOD
    print(answer%MOD)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
MOD = 1000000007  # type: int
from collections import Counter

# 素因数分解
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def solve(N: int):
    soinsuu = prime_decomposition(math.factorial(N))
    counter = Counter(soinsuu)
    answer =1
    for value in counter.values():
        answer = answer*(value+1)
    print(answer%MOD)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def f(x):
  out=[]
  for j in range(2, int(x**(1/2))+1, 1):
    while x%j==0:
      out.append(j)
      x//=j
      if x==1:
        break
  if x!=1:
    out.append(x)
  return out

N=int(input())
mod=10**9+7
nums=[1]*(N+1)
for i in range(2, N+1):
  a=f(i)
  for j in a:
    nums[j]+=1
    
for i in range(3, N+1):
  nums[i]=(nums[i-1]*nums[i])%mod
  
print(nums[-1])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    l = [0 for _ in range(N)]
    is_prime = [True for _ in range(N+1)]
    is_prime[0],is_prime[1] = False,False
    INF = 10**9+7
    
    for i in range(N+1):
        if is_prime[i]:
            for j in range(2*i,N+1,i):
                is_prime[j] = False

    fa = [0 for _ in range(N+1)]                
    for x in range(1,N+1):
        for i in range(1,x+1):
            if (is_prime[i] and x%i == 0):
                while x%i == 0:
                    fa[i] += 1
                    x //= i
 
    ans = 1
    for i in range(N+1):
        ans *= fa[i]+1
        ans %= INF
        
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
F = {}
for n in range(2,N+1):
    _n = n
    f = 2
    while f*f<=_n:
        if n%f==0 and f not in F: F[f] = 0
        while n%f==0:
            n//=f
            F[f]+=1
        f+=1
    if n>1:
        if n not in F: F[n] = 0
        F[n] += 1

ans = 1
mod = 10**9+7
for _, k in F.items():
    ans = ans*(k+1)%mod
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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


candidate = [0] * 1001

candidate[2] = 1
candidate[3] = 1
for i in range(4,N + 1):
    tmp = i
    for j in range(2, int(i ** (1/2)) + 1):
        while tmp % j == 0:
            candidate[j] += 1
            tmp = tmp // j
    candidate[tmp] += 1

ans = 1
for i in range(2,len(candidate)):
    if candidate[i] != 0:
       ans = ans * (candidate[i] + 1) % 1000000007
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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


candidate = [0] * 1001

candidate[2] = 1
candidate[3] = 1
for i in range(4,N + 1):
    tmp = i
    for j in range(2, int(i ** (1/2)) + 1):
        if tmp % j == 0:
            while tmp % j == 0:
                candidate[j] += 1
                tmp = tmp // j
    candidate[tmp] += 1

ans = 1
for i in range(2,len(candidate)):
    if candidate[i] != 0:
       ans = ans * (candidate[i] + 1) % 1000000007
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def trial_division(n):
    '''
    素因数分解する
    '''
    factor = []
    for num in range(2, int(n**0.5)+1):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor or n != 1:
        factor.append(n)
    return factor


N = int(input())
divisor_dict = defaultdict(int)
for i in range(2, N+1):
    divisors = trial_division(i)
    for d in divisors:
        divisor_dict[d] += 1
ans = 1
for v in divisor_dict.values():
    ans = (ans * (v+1)) % (1e9 + 7)
print(int(ans))

Submission status: Accepted

Solution code:
"""
ある整数 x が、素因数分解によって x = p^n × q^m × ... (p, q, ...は素数) と表せる時、
x の約数の個数は(n + 1) × (m + 1) × ... となります。
"""

"""nを素因数分解"""
"""2以上の整数n => return [[素因数, 指数], ...]の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
  
from collections import defaultdict
N = int(input())
MOD = 10**9+7
primes = defaultdict(int)
# N!をループしそれぞれの素因数を取得
for i in range(2, N+1):
  for k, v in factorization(i):
    primes[k] += v

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
MOD = 10**9+7
mp = defaultdict(int)
# N! -> N-1, N-2,...で対応 (1は影響ないから2からスタート)
for i in range(2, N+1) :
  x = i
  for j in range(2, x+1): # 素数jの個数を求める
    while x%j == 0:
      x /= j
      mp[j] += 1
      
ans = 1
for v in mp.values():
  ans = ((ans%MOD) * (v+1)%MOD) % MOD
print(ans)

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
MOD=10**9+7
N=int(input())

S=dict(zip(list(range(1,1001)),[0]*1000))
for n in range(1,N+1):
    D=prime_factorize(n)
    for d in D:
        S[d]+=1

ans=1
for s in S.values():
    ans*=(s+1)%MOD
print(ans%MOD)

Submission status: Accepted

Solution code:
import math
n=int(input())
m=math.factorial(n)
arr=[1]*1000
for i in range(2,1001):
  while m%i==0:
    m//=i
    arr[i]+=1
ans=1
for i in arr:
  ans*=i
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
#52c
import math
import collections

MODBY = 7 + 10**9

N = int(input()) #10**3

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

pf_dict = dict()

for i in range(2,N+1):
    c = collections.Counter(prime_factorize(i))
    for j in c.items():
        if j[0] not in pf_dict:
            pf_dict[j[0]] = j[1]
        else:
            pf_dict[j[0]] += j[1]

ans = 1
for i in  pf_dict.values():
    ans = ans*(i+1)
    
print(ans%MODBY)

Submission status: Accepted

Solution code:
n = int(input())
prime_dic = {}

def prime_factorization(n):
    count = 0
    while n % 2 == 0:
        count += 1
        n = n / 2
    
    if 2 in prime_dic.keys():
        prime_dic[2] += count
    else:
        two = {2:count}
        prime_dic.update(two)

    f = 3
    count = 0
    while f*f <= n:
        if n % f == 0:
            
            if f in prime_dic.keys():
                prime_dic[f] += 1
            else:
                new = {f:1}
                prime_dic.update(new)
            n = n / f
        else:
            f += 2
    if n != 1:
        if n in prime_dic.keys():
            prime_dic[n] += 1
        else:
            new = {n:1}
            prime_dic.update(new)
    return 

for i in range(2,n+1):
    prime_factorization(i)

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

print(ans)

Submission status: Accepted

Solution code:
# 「約数の個数」でググると素因数ひとつひとつに対して+1したものをかけあわせた数らしい
# あらかじめ10^3までの素数を抽出しておき、素因数を全探索、答えを更新していく
# 10^3までの素数列挙にはエラトステネスを使う

primes = []
numbers = [False for _ in range(10 ** 3 + 1)]

for i in range(2, 10 ** 3 + 1):
    if numbers[i] == False:
        primes.append(i)
        for j in range(i, 10 ** 3 + 1, i):
            numbers[j] = True

n = int(input())
ans = 1
MOD = 10 ** 9 + 7
d = {}

for i in range(2, n + 1):
    tmp = i
    for p in primes:
        while tmp % p == 0 and tmp != 0:
            d[p] = 1 if p not in d else d[p] + 1
            tmp //= p

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

#nを素因数分解したリストを返す
def prime_decomposition(n):
   i = 2
   table = []
   while i * i <= n:
       while n % i == 0:
           n /= i
           table.append(i)
       i += 1
   if n > 1:
       table.append(n)
   return table

from collections import defaultdict
dic = defaultdict(int)
for i in range(n+1):
    for k in prime_decomposition(i):
        dic[k] += 1

ans = 1
for i in dic.values():
    ans *= i+1
    ans %= 10**9+7

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
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 = {}
for i in range(2, n+1):
  a = factorization(i)
  for i in a:
    if i[0] not in d.keys():
      d[i[0]] = i[1]
    else:
      d[i[0]] += i[1]
ans = 1
for value in d.values():
  ans *= value+1
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
from math import factorial

N = int(input())
mod = 10**9+7
fn = factorial(N)

ans = 1
for i in range(2, N+1):
    count = 1
    while fn % i == 0:
        count += 1 
        fn //= i 
    ans *= count
print(ans%mod)

Submission status: Accepted

Solution code:
import math

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

def get_sieve_of_eratosthenes(n):
    if n==1:
        return []
    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]

# エラトステネスの篩を使い、素数のリストを作る
E=get_sieve_of_eratosthenes(n)
# 素数の数を数える
l=len(E)
#print("len(e): ",l)

# カウンタ
co=1
# 0から素数までの値で、nを何回割れるかを数える
for e in E:
    co_sub=1
    # 対数。n=25,e=5の時,2を返す(5**"2"==25)
    l_sub=int(math.log(n,e))
    # 対数の数だけ繰り返す
    for j in range(1,l_sub+1):
        # 割れる回数をカウンタに追加
        co_sub+=n//(e**j)
    co*=co_sub
    # 大きすぎるのでmodのあまりにする
    co%=mod
    #print(co_sub)
print(co)

Submission status: Accepted

Solution code:
import math


def sieve_of_eratosthenes(n):
    if n == 1:
        return []
    limit = int(math.sqrt(n))
    targets = [i for i in range(2, n + 1)]
    primes = []
    while targets[0] <= limit:
        p = targets[0]
        primes.append(p)
        targets = [i for i in targets if i % p != 0]
    primes.extend(targets)
    return primes


n = int(input())
p = sieve_of_eratosthenes(n)
ans = 1
for i in p:
    cnt = 0
    for j in range(2, n + 1):
        while j % i == 0:
            j //= i
            cnt += 1
    ans *= cnt + 1
    ans %= 10 ** 9 + 7
print(ans)

Submission status: Accepted

Solution code:
import math


def sieve_of_eratosthenes(n):
    if n == 1:
        return []
    limit = int(math.sqrt(n))
    targets = [i for i in range(2, n + 1)]
    primes = []
    while targets[0] <= limit:
        p = targets[0]
        primes.append(p)
        targets = [i for i in targets if i % p != 0]
    return primes + targets


n = int(input())
p = sieve_of_eratosthenes(n)
ans = 1
for i in p:
    cnt = 0
    for j in range(2, n + 1):
        while j % i == 0:
            j //= i
            cnt += 1
    ans *= cnt + 1
    ans %= 10 ** 9 + 7
print(ans)

Submission status: Accepted

Solution code:
import math


def sieve_of_eratosthenes(n):
    max_prime = int(math.sqrt(n))
    targets = [i for i in range(2, n + 1)]
    primes = []
    if n == 1:
        return primes
    while targets[0] <= max_prime:
        p = targets[0]
        primes.append(p)
        targets = [i for i in targets if i % p != 0]
    primes.extend(targets)
    return primes


n = int(input())
p = sieve_of_eratosthenes(n)
ans = 1
for i in p:
    cnt = 0
    for j in range(2, n + 1):
        while j % i == 0:
            j //= i
            cnt += 1
    ans *= cnt + 1
    ans %= 10 ** 9 + 7
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1
mod=10**9+7

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

data=[1]*10**4
n=int(input())
for i in range(2,n+1):
    for ai ,c in prime_factor(i):
        data[ai]=(data[ai]+c)%mod
for di in data:
    pro*=di
    pro%=mod
print(pro)

Submission status: Accepted

Solution code:
import math
import collections
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

c = collections.Counter(prime_factorize(math.factorial(N)))
prime_factors = list(c.values())
answer = 1

for i in range(len(prime_factors)):
    answer *= (prime_factors[i] + 1)

print(answer % mod)

Submission status: Accepted

Solution code:
import math
import collections
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
# print(math.factorial(N))
# print(prime_factorize(math.factorial(N)))

c = collections.Counter(prime_factorize(math.factorial(N)))
# print(list(c.values()))
orion = list(c.values())
unizon = 1
for i in range(len(orion)):
    unizon *= (orion[i]+1)
# for i in range(len(c.values())):
print(unizon % mod)

Submission status: Accepted

Solution code:
import sys
from math import floor, sqrt
from collections import defaultdict

MOD = 10 ** 9 + 7

n = int(sys.stdin.readline().rstrip())

res = defaultdict(int)

def primeFactorize(n):
    while n % 2 == 0:
        res[2] += 1
        n //= 2
    if n == 1:
        return
    for i in range(3, floor(sqrt(n))+1, 2):
        while n % i == 0:
            res[i] += 1
            n //= i
        if n == 1:
            return
    res[n] += 1

def main():
    for i in range(1, n+1):
        primeFactorize(i)
    
    ans = 1
    for c in res.values():
        ans *= c + 1
        ans %= MOD
    
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

Solution code:
def prm(a):
  if a==1 or a == 4:
    return False
  for i in range(2,int(a**0.5+1)):
    if a%i==0:
      return False
  else:
    return True
x=int(input())
d=[1]*(x+1)
for i in range(1,x+1):
  if prm(i):
    d[i]+=1
  else:
    while not prm(i) and i != 1:
      for j in range(2,i):
        if i%j==0:
          d[j]+=1
          i=i//j
          break
    if i!= 1:
      d[i]+=1
ans=1

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

Submission status: Accepted

Solution code:
from collections import defaultdict


def factorize2(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


MOD = 10 ** 9 + 7
N = int(input())
d = defaultdict(int)
for i in range(1, N + 1):
    for n, c in factorize2(i):
        d[n] += c

ans = 1
for n, c in d.items():
    ans *= c + 1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
klist=[]
MOD=10**9+7
ans=1
kaijo=list(range(n+1))
for i in range(2,n+1):
    kaisu=0
    for j in range(1,n+1):
        while kaijo[j]%i==0:
            kaijo[j]=kaijo[j]//i
            kaisu+=1
    if kaisu!=0:
        klist.append(kaisu%MOD)
for i in range(len(klist)):
    ans*=((klist[i]+1)%MOD)
ans=ans%MOD
print(ans)

Submission status: Accepted

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

P=[0]*1000
x=1
N=int(input())
for i in range(2,N+1):
  A=PF(i)
  for j in range(len(A)):
    P[A[j][0]]=P[A[j][0]]+A[j][1]
P.remove(0)
for i in range(len(P)):
  x=(x*(P[i]+1))%(10**9+7)
print(x)

Submission status: Accepted

Solution code:
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table
N=int(input())
_, table = sieve(N)
d={}
for p in table:
    sum_=0
    calc=p
    while calc <= N:
        sum_ += N//calc
        calc *= p
    d[p] = sum_
    
lim = 10**9+7
ans=1
for i in d.values():
    ans = (ans * (i+1)) % lim
print(ans)

Submission status: Accepted

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

n = int(input())
p = [0] * 1001
for i in range(2, n + 1):
    for j in PF(i):
        p[j[0]] += j[1]

ans = 1
mod = int(1e9 + 7)
for i in range(2, n + 1):
    ans = ans * (p[i] + 1) % mod
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print(1)
    exit()
P = 10**9+7
d = {}
for i in range(2,N+1):
    k = i
    for j in range(2,i):
        while i%j == 0:
            i = i//j
            if j in d.keys():
                d[j] += 1
            else:
                d[j] = 1
    if k == i:
        d[i] = 1
ans = 1
for v in d.values():
    ans = ans*(v+1)%P
print(ans)

Submission status: Accepted

Solution code:
import collections
import math

def trial_division(n):
    if n < 2:
        return []

    prime_factors = []

    for i in range(2, int(n**0.5)+1):
        # nがi（の累乗）で割り切れるかを調べる
        while n % i == 0:
            # nがiで割り切れる場合、iを素因数としてリストに追加する
            prime_factors.append(i)
            # nをiで割った商で更新しておく
            n //= i
    # nの平方根より大きい素因数が存在する場合
    if n > 1:
        prime_factors.append(n)

    return prime_factors

n = int(input())
mod = 10**9+7
ans = 1
pf = []
f = math.factorial(n)
# print('factorial:', f)

for i in range(2, n+1):
    # print(i, trial_division(i))
    pf += trial_division(i)

# print('pf:', pf)

pfMap = collections.Counter(pf)
# print('pfMap:', pfMap)

for key, value in pfMap.items():
    ans *= value + 1
    ans %= mod

print(ans % mod)

Submission status: Accepted

Solution code:
n = int(input())

primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

d = dict()
for i in range(len(primes)):
    d[primes[i]] = 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

l = [0] * len(primes)
for i in range(1, n+1):
    divisors = prime_factorize(i)
    for dv in divisors:
        idx = d[dv]
        l[idx] += 1
    # print(l)
    tmp = 1
    for j in range(len(primes)):
        tmp *= (l[j] + 1)

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

Submission status: Accepted

Solution code:
import math

n=int(input())

def get_sieve_of_eratosthenes(n):
    if n==1:
        return []
    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]

e=get_sieve_of_eratosthenes(n)
l=len(e)

co=1
for i in range(l):
    k=e[i]
    co_sub=1
    l_sub=int(math.log(n,k))
    for j in range(1,l_sub+1):
        co_sub+=n//(k**j)
    co*=co_sub
    co%=(10**9+7)
    #print(co_sub)
print(co)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


MOD = 10 ** 9 + 7
N = int(input())


# In[2]:


# N = 1000


# In[3]:


yakusu = [0 for _ in range(10**3 + 1)]
for n in range(2, N+1):
    for i in range(2, 10 ** 3):
        count = 0
        while n % i == 0:
            count += 1
            n //= i
        if count > 0:
            yakusu[i] = (yakusu[i]+count) % MOD
        if n == 1:
            break
    


# In[4]:


yakusu


# In[5]:



ans = 1
for i in yakusu:
    if i > 0:
        ans = ans * (i+1) % MOD
print(ans)


# In[ ]:

Submission status: Accepted

Solution code:
N = int(input())
prime = []
l = [False] * (N+1)

for i in range(2, N+1):
  if l[i]: continue
  prime.append(i)
  j = 1
  while i * j <= N:
    l[i * j] = True
    j += 1

ans = 1
for i in prime:
  r = 1
  j = 1
  while i ** j <= N:
    k = 1
    while i ** j * k <= N:
      r += 1
      k += 1
    j += 1
  ans = ans * r % (10 ** 9 + 7)

print(ans)

Submission status: Accepted

Solution code:
import math


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():
    N = int(input())
    MOD = 10**9 + 7

    A = [0 for _ in range(N + 1)]
    for i in range(2, N + 1):
        x = factorization(i)
        for a, b in x:
            A[a] += b

    ans = 1
    for a in A:
        ans *= (a + 1)
        ans %= MOD

    print(ans)


main()

Submission status: Accepted

Solution code:

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

# 階乗のそれぞれの要素について素因数分解する
for i in range(2,N+1):
    p = 2
    x = i
    # 割り切れる間は素因数で割る
    while p * p <= x:
        while x % p == 0:
            d[p] += 1
            x //= p
        p += 1
    # 割り切れなくなったときに残って居たらそれも素因数なので追加する
    if x > 1:
        d[x] += 1
    
ans = 1
for k in d.keys():
    ans *= (d[k] + 1)

print(ans%MOD)

Submission status: Accepted

Solution code:
import math
def trial_division(n):
    a = []
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    if n != 1:
        a.append(n)
    return a
N = int(input())
MOD = 10**9 + 7
ans_arr = [1]*(N+1)
for i in range(2,N+1):
    for item in trial_division(i):
        ans_arr[item] += 1
ans = 1
for item in ans_arr:
    ans *= item
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
MOD = 10**9+7
N = int(input())
ans = 1
ary = defaultdict(int)
for i in range(1, N+1):
    n = i
    m = 2
    while n > 1:
        if not n % m:
            ary[m] += 1
            n //= m
            m = 1
        m += 1
for v in dict(ary).values():
    ans *= v+1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
import math


def f(n):
    r = dict()
    while n != 1:
        for i in range(2, n+1):
            while n % i == 0:
                r[i] = r.get(i, 0) + 1
                n //= i
    return r


def main():
    N = int(input())
    ds = []
    for i in range(2, N+1):
        x = f(i)
        ds.append(x)
    # print(ds)

    d = {}
    for di in ds:
        for k in di.keys():
            v = di.get(k)
            # print(k, d)
            d[k] = d.get(k, 0) + v

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



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
import numpy as np
lis=np.array([1]*N)
mod=10**9+7
def prime_fac(n,l):
  for i in range(2,int(n**(1/2))+1):
    count=0
    while n%i==0:
      n=n//i
      count+=1
      
    l[i-1]+=count
    
  if n!=1:
    l[n-1]+=1
  return l
  
for i in range(2,N+1):
  lis=prime_fac(i,lis)
  
ans=1
lis=lis[lis>1]
for i in lis:
  ans=ans*i%mod
print(ans)