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:
import math
import copy

def trial_division(n):
    check = 0
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp+1):
        while n % num == 0:
            n /= num
            factor.append(num)
            check = 1
    #素数チェック
    if check == 0:
        factor.append(n)
    return factor

n = int(input())
ans = 1

div = []
for i in range(2,n+1):
    for j in trial_division(i):
        div.append(j)
        div = list(set(div))

for i in div:
    x = 0
    for j in range(i,n+1):
        num = j
        while num % i == 0:
            x += 1
            num /= i
    ans = (ans*(x+1))%(10**9+7)

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

d = defaultdict(int)

def trial_division(n):
    
    tmp = int(n ** 0.5) + 1
    for num in range(2, tmp):
        while n % num == 0:
            d[num] += 1
            n //= num
    if n > 1:
        d[n] += 1

    return

N = int(input())

for i in range(1, N+1):
    trial_division(i)

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

Submission status: Accepted

Solution code:
from collections import defaultdict


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

    if n != 1:
        ps.append(n)

    return ps


d = defaultdict(lambda: 0)
n = int(input())
for i in range(2, n+1):
    fs = factors(i)
    for f in fs:
        d[f] += 1


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

print(c)

Submission status: Accepted

Solution code:
# https://abc052.contest.atcoder.jp/tasks/arc067_a
import collections
import math
import sys

BIGINT = 1000000007
N = int(input())
counts = collections.defaultdict(int)

for n in range(2, N+1):
    for d in range(2, int(math.sqrt(n)) + 1):
        while n % d == 0:
            n = n // d
            counts[d] += 1
    if n > 1:
        counts[n] += 1

# print("counts:", counts, file=sys.stderr)

res = 1
for v in counts.values():
    res = (res * (v + 1) % BIGINT)

print(res)

Submission status: Accepted

Solution code:
def prime(n):
  if n==1:
    return False
  elif n==2 or n==3:
    return True
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      return False
  else:
    return True

n=int(input())
primes=[]
for i in range(1,n+1):
  if prime(i):
    primes.append(i)
arr=[0]*(n+1)
for i in range(1,n+1):
  for j in primes:
    if j>i:
      break
    if i%j==0:
      arr[j]+=1
      i=i//j
      while i>1:
        if i%j==0:
          arr[j]+=1
          i=i//j
        else:
          break
ans=1
for i in primes:
  ans=(ans*(arr[i]+1))%(10**9+7)
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
def prime(x):
    y = list(range(1, x + 1))
    y[0] = 0
    x_sqrt = x ** 0.5
    for i in y:
        if i > x_sqrt:
            break
        elif i == 0:
            continue
        for not_prime in range(2 * i, x + 1, i):
            y[not_prime - 1] = 0
    return [i for i in y if i > 0]

n = int(input())
MOD = 10 ** 9 + 7
primes = prime(n)
m = [0 for _ in range(len(primes))]
for i, p in enumerate(primes):
    for j in range(1, n + 1):
        while(j % p == 0):
            m[i] += 1
            j = j // p
ans = 1
for i in m:
    ans *= (i + 1)
    ans = ans % MOD
print(ans)

Submission status: Accepted

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

pl=primes(k)
ans=[]
m=math.factorial(k)
for i in range(len(pl)):
    tmp=0
    while m%pl[i]==0:
        m=m//pl[i]
        tmp+=1
    ans.append(tmp)
a=1
for i in range(len(ans)):
    a=a*(ans[i]+1)%(10**9+7)
print(a)

Submission status: Accepted

Solution code:
N = int(input())

MOD = 10 ** 9 + 7

d = dict()

for i in range(2, N+1):
    for j in d.keys():
        while i % j == 0:
            i //= j
            d[j] += 1
    if i != 1:
        d[i] = 1

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
p=[2]
for i in range(3,n+1,2):
    for j in range(3,int(i**0.5)+1,2):
        if i%j==0:break
    else:p.append(i)
l=[0]*len(p)
for i in range(1,n+1):
    while i!=1:
        for j,k in enumerate(p):
            if i%k==0:
                l[j]+=1
                i//=k
ans=1
for i in l:ans=ans*(i+1)%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
pList={}
mod = 10**9+7
def soinsuu(x):
    if x==1:return
    for p in pList:
        if x%p==0:
            pList[p] += 1
            return soinsuu(x//p)
    pList[x] = pList.get(x,0)+1
    return
for n in range(2,N+1):
    soinsuu(n)
ans = 1
for i in pList.values():
    ans = (ans*(i+1))%mod
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())

power = defaultdict(int)
for k in range(2, N + 1):
    _k = k
    for p in range(2, k + 1):
        while _k % p == 0:
            power[p] += 1
            _k //= p
ans = 1
for n in power.values():
    ans *= n + 1
print(ans % (10 ** 9 + 7))

Submission status: Accepted

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

import math

def solve(N):
    F = math.factorial(N)
    ans = 1
    
    for i in range(2, N + 1):
        count = 1
        while(F%i == 0):
            F //= i
            count += 1
        ans *= count
        
    print(ans % (10**9+7))

if __name__ == '__main__':
    N = int(input())
    
    solve(N)

Submission status: Accepted

Solution code:
N = int(input())

prime_dict = {}
# N!の各要素の素因数を合わせたものの指数部分＋１をかけ合わせていく
# その素因数を個数分選ぶか選ばないか選択するのに相当する
# 1は素数でないし、素因数を何も選ばなかった場合に相当するので放置
# 素因数分解はO(logN)でそれを個数分なので、時間計算量はO(NlogN)となり、N<=10^3なので十分間に合う
while N > 1:
  pn = 2
  tmp = N
  while pn * pn <= tmp:
    while tmp % pn == 0:
      tmp = tmp / pn
      prime_dict[pn] = prime_dict.get(pn, 0) + 1
    pn += 1
  if tmp > 1:
    prime_dict[tmp] = prime_dict.get(tmp, 0) + 1
  N -= 1

cnt = 1  
for key in prime_dict.keys():
  cnt *= prime_dict[key]+1
  
print(cnt % (10**9+7))

Submission status: Accepted

Solution code:
N = int(input())

prime_dict = {}

while N > 1:
  pn = 2
  tmp = N
  while pn * pn <= tmp:
    while tmp % pn == 0:
      tmp = tmp / pn
      prime_dict[pn] = prime_dict.get(pn, 0) + 1
    pn += 1
  if tmp > 1:
    prime_dict[tmp] = prime_dict.get(tmp, 0) + 1
  N -= 1

cnt = 1  
for key in prime_dict.keys():
  cnt *= prime_dict[key]+1
  
print(cnt % (10**9+7))

Submission status: Accepted

Solution code:
import math
N = int(input())
F = math.factorial(N)
ans = 1
for i in range(2, N + 1):
    cnt = 1
    while F % i == 0:
        F //= i
        cnt += 1
    ans *= cnt
print(ans % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
from math import factorial

N = int(input())

F = factorial(N)
result = 1
for i in range(2, N + 1):
    count = 1
    while F % i == 0:
        F //= i
        count += 1
    result *= count

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

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter

N = int(input())

memo = []
for n in range(2, N + 1):
    k = 2
    while k * k <= n:
        count = 0
        while n % k == 0:
            n //= k
            memo.append(k)
        k += 1
    if n > 1:
        memo.append(n)

MOD = 10 ** 9 + 7
result = 1
for n in Counter(memo).values():
    result = (result * (n + 1)) % MOD
print(result)

Submission status: Accepted

Solution code:

import math

def func(val):
    d = range(2, val+1)
    ans = []

    for i in range(2, val+1):
        if i in d:
            ans.append(i)
            d = [n for n in d if n % i != 0]
    #print(ans)
    return ans

n = int(input())

p = 1
pn_list = {}
for l in range(2, n+1):
    for pn in func(l):
        m = 0
        while(1):
            if l % pn != 0:
                break
            else:
                l /= pn
                m += 1
        
        pn_list.setdefault(pn, 0)
        pn_list[pn] += m

p = 1
for v in pn_list.values():
    p *= (v+1)

ans = p % (10**9 + 7)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
K = eval("*".join(map(str, list(range(1, N+1)))))
ans = 1
for i in range (2, N + 1):
    num = 0
    while K % i == 0:
        num += 1
        K //= i
    ans *= (num + 1)
print(ans % (10**9 + 7))

Submission status: Accepted

Solution code:
def get_primes(n):
	primes = [True for i in range(n+1)]
	primes[0] = False
	primes[1] = False
	for i in range(2, n+1):
		if i*i > n:
			break
		if not primes[i]:
			continue
		for non_prime in range(2 * i, n+1, i):
			primes[non_prime] = False
	return [i for i, prime in enumerate(primes) if prime]


def main():
	N = int(input())
	ans = 1
	DIV = 10**9+7
	primes = get_primes(N)
	d = [1]*len(primes)

	for i, p in enumerate(primes):
		q = p
		while N >= q:
			d[i] += N//q
			q *= p

	for div_num in d:
		ans *= div_num
		ans %= DIV
	print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def is_prime(n):
    if n == 2:
        return True
    else:
        for i in range(2, int((n**(1/2)))+1):
            if n % i == 0:
                return False
        return n > 1

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

primes = [i for i in range(N+1) if is_prime(i)] # N以下の素数

c = Counter(primes) # 各素数で何回割れるかを記録する
                    # 最後に約数の個数を求める時、
                    # (各素因数の指数+1)を掛け合わせるので1で初期化されるCounterは都合が良い

# N以下の数について、各素数で割れた回数を数えていく
for j in range(2, N+1):
    for prime in primes:
        while j % prime == 0:
            j //= prime
            c[prime] += 1

ans = 1
for cnt in c.values():
    ans *= cnt # 初期値が1なので1を足す必要はない
print(ans%MOD) # 剰余で答えるのを忘れずに

Submission status: Accepted

Solution code:
from collections import defaultdict

def read_input():
    n = int(input())

    return n


def factorizer(x):
    limit = x

    factors = []
    t = x
    for i in range(2, limit + 1):
        while t % i == 0:
            factors.append(i)
            t /= i

    if not factors:
        factors.append(x)

    return factors


def submit():
    n = read_input()

    factors_occur = defaultdict(int)

    for i in range(2, n + 1):
        factors = factorizer(i)

        for f in factors:
            factors_occur[f] += 1

    occurs = [o for (k, o) in factors_occur.items()]

    acc = 1
    maxmod = (10**9) + 7
    for power in occurs:
        acc *= (power + 1)

    print(acc % maxmod)

if __name__ == '__main__':
    submit()

Submission status: Accepted

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

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

    primes = [i for i in range(n)]
    primes[1] = 0

    # エラトステネスのふるい
    for prime in primes:
        if prime**2 > n:
            break
        if not prime:
            continue
        for non_prime in range(2 * prime, n, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

d = {}
for p in get_primes(n+1):
    q = p
    while n >= q:
        d[p] = d.get(p, 1) + n//q
        q *= p
ans = 1
for i in d.values():
    ans *= i
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
N = int(input())


def prime_factorize(N: int) -> list:
    res = []
    pn = 2
    while N != 1:
        exp = 0
        while N % pn == 0:
            N /= pn
            exp += 1
        if exp:
            res.append([pn, exp])
        pn += 1
    return res


pn = []
for i in range(2, N+1):
    for j in prime_factorize(i):
        flg = 0
        if pn:
            idx = 0
            for k in pn:
                if k[0] == j[0]:
                    pn[idx][1] += j[1]
                    flg = 1
                    break
                idx += 1
        if not flg:
            pn.append(j)

ans = 1
for i in pn:
    tmp = (i[1] + 1) % (10**9 + 7)
    ans *= tmp
    ans %= (10**9 + 7)

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
num = Counter()
for n in range(1, N + 1):
    factors = prime_factors(n)
    num.update(factors)
x = 1
for _, n in num.items():
    x *= (n + 1)
    x %= 10 ** 9 + 7
print(x)

Submission status: Accepted

Solution code:
N = int(input())

ans = 1
soin = {}

for i in range(2, N+1):
    k = i
    for j in range(2, i+1):
        while(k//j == k/j):
            if j in soin:
                soin[j] += 1
            else:
                soin[j] = 1
            k //= j

        if k == 1:
            break

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
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

cnt = Counter()
for i in range(1,n+1):
    cnt.update(factorize(i))

ans = 1
for key in cnt.keys():
    ans *= cnt[key] + 1
    ans = ans % MOD
print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())

lim = n

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
prime = callIsPrime(n+1)

arr = [0] * len(prime)

for i in range(len(prime)):
  j = 1
  while n >= prime[i] ** j :
    arr[i] += int(n / prime[i] ** j)
    j += 1
  
ans = 1
for i in arr :
  if i != 0:
    ans *= i+1

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
n = int(input())

n_frac = math.factorial(n)

_n_frac = n_frac
prime_numbers = {}

for i in range(2, n_frac +1):
    if _n_frac == 1:
        break
    while True:
        div, mod = divmod(_n_frac, i)
        if mod != 0:
            break
        _n_frac = div
        if i in prime_numbers:
            prime_numbers[i] += 1
        else:
            prime_numbers[i] = 1

n_divisor = reduce(lambda x,y:x*(y+1), prime_numbers.values(), 1 )
result = n_divisor % (10**9 +7)

print(result)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

def sieve(n):
    """Sieve of Eratosthenes"""
    if n < 2:
        is_prime = [False for _ in range(n+1)]
        return is_prime

    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False

    prime = []
    for i in range(n+1):
        if is_prime[i]:
            prime.append(i)

    return prime


def main():
    input = sys.stdin.readline
    N = int(input())
    MOD = 10**9 + 7

    if N == 1:
        return 1

    prime = sieve(N)
    d = defaultdict(lambda: 0)
    for i in range(2, N+1):
        m = i
        for p in prime:
            if p > m:
                break

            while m % p == 0:
                d[p] += 1
                m //= p
    
    ans = 1
    for key in d.keys():
        ans *= d[key] + 1

    return ans % MOD


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

Submission status: Accepted

Solution code:
import math


# 素数判定
def is_prime(n):
    for i in range(2, int(math.sqrt(n) + 1)):
        if n % i == 0:
            return False
    return True


# 約数列挙
def get_divisor(n, is_sort=False):
    divisors = [1]
    for i in range(2, int(math.sqrt(n) + 1)):
        if n % i == 0:
            divisors.append(i)
            other_div = n // i
            if i != other_div:
                divisors.append(other_div)
    divisors.append(n)
    if is_sort:
        divisors.sort()
    return divisors


# 素因数分解
def prime_factor(n):
    factors = {}
    for i in range(2, int(math.sqrt(n) + 1)):
        if n % i == 0:
            factors[i] = 0
        while n % i == 0:
            n = n // i
            factors[i] += 1
        if n == 1:
            break
    if n != 1:
        factors[n] = 1
    return factors


if __name__ == '__main__':
    n = int(input())
    prime_dict = {}
    for i in range(2, n + 1):
        prime_dict[i] = 1
        for key, value in prime_factor(i).items():
            prime_dict[key] += value

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

Submission status: Accepted

Solution code:
n = int(input())
t = [0]*n
f = 1
mod = 10**9+7
for i in range(2,n+1):
  fa = 1
  while i > 1:
    fa += 1
    while i % fa == 0:
      i = i//fa
      t[fa-2] += 1

for j in range(n):
  f = f*(t[j]+1)%mod
print(f)

Submission status: Accepted

Solution code:
N = int(input())
import math
def is_prime(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False

    # 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True
  
def make_prime_list(num):
    if num < 2:
        return []

    prime_list = []
    for prime in range(2, num + 1):
        if is_prime(prime):
            prime_list.append(prime)
    return prime_list
  
num = N
prime_list = make_prime_list(num)
pcount={}
for p in prime_list:
    pcount[p]=0
for nn in range(2,num+1):
    for p in prime_list:
        n=nn
        if n<p:
            break
        while n%p==0:
            n//=p
            pcount[p]+=1
            
ans = 1
for i in pcount.values():
    ans *= (i + 1)
print(ans % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    factor = []
    f = math.factorial(N)
    dict = {}
    ans = 1
    for num in range(2,1000):
        while f % num == 0:
            f //= num
            factor.append(num)
            if num in dict:
                dict[num] += 1
            else:
                dict[num] = 1
    for v in dict.values():
        ans *= v + 1

    print(ans % (10**9 + 7))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

PN = []
def buildPrimeNumber(N):
	global PN
	for n in range(2, N + 1):
		f = True
		for m in range(2, n):
			if 0 == n % m:
				f = False
				break
		if f:
			PN.append(n)

buildPrimeNumber(1000)

C = dict()
def primeFactorization(N):
	global C
	for pn in PN:
		if N % pn:
			continue
		c = 0
		while 0 == N % pn:
			c += 1
			N //= pn
		C[pn] = c
	if N == 1:
		return
	else:
		C.clear()

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

primeFactorization(f)

r = 1
for c in C.values():
	r *= (c + 1)
print(r % (10**9 + 7))

Submission status: Accepted

Solution code:
n=int(input())
x=1
for i in range(1,n+1):
    x*=i

res=1

for i in range(2,n+1):
    cnt=1
    while x%i==0:
        x=x//i
        cnt+=1
    res*=cnt
    
print(res%(10**9+7))

Submission status: Accepted

Solution code:
def is_prime(n):
    if n <= 1:
        return False
    elif n == 2:
        return True
    else:
        for i in range(2, int((n**(1/2)))+1):
            if n % i == 0:
                return False
        return True

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

primes = [i for i in range(N+1) if is_prime(i)] # N以下の素数

c = Counter(primes) # 各素数で何回割れるかを記録する
                    # 最後に約数の個数を求める時、
                    # (各素因数の指数+1)を掛け合わせるので1で初期化されるCounterは都合が良い

for j in range(2, N+1):
    for prime in primes:
        while j % prime == 0:
            j //= prime
            c[prime] += 1

ans = 1
for cnt in c.values():
    ans *= cnt # 初期値が1なので1を足す必要はない
print(ans%MOD)

Submission status: Accepted

Solution code:
def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num / pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
  return pflist

mod = (10 ** 9 + 7)
N = int(input())
ans = 0


pf_dict = {}
#素因数がキー、割れる回数を値として用意し、最後に約数の個数を求める
for i in range(2, N+1):

  pflist = getPrimeFactorsList(i)
  pfset = set(pflist)
  for j in pfset:
    if j in pf_dict:
      pf_dict[j] += pflist.count(j)
    else:
      pf_dict[j] = pflist.count(j)
    #count *= (pflist.count(j) + 1)
  
count = 1
for v in pf_dict.values():
  count *= (v + 1)
print(count % mod)

Submission status: Accepted

Solution code:
N = int(input())
prime = [0]*(N+1)
ans = 1
for i in range(2,N+1):
    d = 1
    while i > 1:
        d+=1
        while i % d == 0:
            i = i//d
            prime[d]+= 1
for j in range(N+1):
    ans = ans *(prime[j]+1)%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
dic = defaultdict(int)
for n in range(2, N + 1):
    for i in range(2, n):
        if i * i > n:
            break
        while n % i == 0:
            dic[i] += 1
            n //= i
    if n > 1:
        dic[n] += 1
ans, MOD = 1, 10 ** 9 + 7
for key in dic:
    ans = ans * (dic[key] + 1) % MOD
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def dict_count(dict, key):
	if key in dict:
		dict[key] = dict[key]+1
	else:
		dict[key] = 1
	return dict

N = int(input())
divs = {}
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
for n in range(2, N+1):
	for p in primes:
		while n%p==0:
			divs = dict_count(divs, p)
			n = n//p
		if p*p>n:
			break
	if n!=1:
		dict_count(divs, n)
result = 1
base = 10**9+7
for c in divs.values():
	result = (result*(c+1))%base
print(result)

Submission status: Accepted

Solution code:
from math import sqrt, ceil


def mul(iterable, mod: int = None)->int:
    ret = 1
    for v in iterable:
        ret *= v
        if mod:
            ret %= mod
    return ret


def factors_of_factorial(N: int)->int:
    prime_factors = {}

    for n in range(2, N+1):
        d = 2
        while n > 1:
            if n % d == 0:
                prime_factors.setdefault(d, 0)
            while n % d == 0:
                prime_factors[d] += 1
                n //= d
            d += 1
    return mul((p+1 for p in prime_factors.values()), mod=10**9+7)


if __name__ == "__main__":
    N = int(input())
    ans = factors_of_factorial(N)
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

for p in prime:
	cnt = 0
	i = p
	while i <= n:
		cnt+=n // i
		i*=p
	ans = ans * (cnt + 1) % 1000000007

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
factors2 = []
for i in range(N):
    factors2.extend(prime_factors(i+1))
cc = Counter(factors2)
ans = 1
inf = 10 ** 9 + 7 
for c in cc.items():
    ans *= c[1]+1
if N == 1:
    print(1)
else:
    print(ans % inf)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
primes = [2,3,5,7,11,13,17,19,23,29,31,37]
mod=int(1e9+7)

memo={}
for n in range(1,N+1):
  for p in primes:
    while not n%p:
      memo[p] = memo.get(p,0)+1
      n=n//p
  if n!=1:
    memo[n] = memo.get(n,0)+1

#print(memo)

answer=1
for v in memo.values():
  answer =answer * (v+1) %mod
print(answer)

Submission status: Accepted

Solution code:
import math
MOD = 10 ** 9 + 7

N = int(input())

prime_list = [2]
for i in range(2, N + 1):
    if all(i % j != 0 for j in range(2, math.ceil(math.sqrt(i)) + 1)):
        prime_list.append(i)

d = {}
for prime in prime_list:
    d[prime] = 0


for i in range(2, N + 1):
    num = i
    for prime in prime_list:
        if num % prime == 0:
            while True:
                d[prime] += 1
                num /= prime
                if num % prime != 0:
                    break 

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

Submission status: Accepted

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

import math

n = int(input())

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

def divisor(fac):
    temp = 1
    for i in range(len(fac)):
        temp *= (fac[i][1] + 1)
    return temp

print(divisor(factorize(math.factorial(n))) % 1000000007)

Submission status: Accepted

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