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:
N = int(input())

prime = [2]
for i in range(3,1001):
    flag = 0
    for j in prime:
        if i % j == 0:
            flag = 1
    if flag == 0:
        prime.append(i)

prime_count = [0 for i in range(1001)]

for i in range(1, N+1):
    for j in prime:
        while i % j == 0:
            prime_count[j] += 1
            i = int(i/j)
ans = 1
for i in range(1001):
    ans *= (prime_count[i]+1)
    ans %= 1000000007
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[0]*(n+1)
ans=1
for i in range(2,n+1):
    x=i
    p=2
    while x>1:
        while x%p==0:
            a[p]+=1
            x//=p
        p+=1
for i in a:
    ans=(ans*(i+1))%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

p=[]
for k in range(2,n+1):
  flag = True
  for i in p:
    if k%i == 0:
      flag = False
      break
  if flag:
    p += [k]

a = 1
for i in p:
  s = 1
  x = n//i
  while x>0:
    s += x
    x = x//i
  a = a*s%1000000007
print(a)

Submission status: Accepted

Solution code:
n = int(input())
cnt = [0]*(n+1)
for i in range(2,n+1):#2~n
    s = i
    while s != 1:
        for j in range(2,n+1):#2~n
            if s % j == 0:
                s //= j 
                cnt[j] += 1
                break

c = 1
for i in range(2,n+1):
    c *=(cnt[i]+1)
    c %=(10**9+7)

print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

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


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


divisor = {}
for i in range(2, n + 1):
    primes = prime_factorization(i)
    for p in primes:
        if p in divisor:
            divisor[p] += 1
        else:
            divisor[p] = 1

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

Submission status: Accepted

Solution code:
N = int(input())
fact = 1
mod = 10**9 + 7

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

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]]


for i in range(1,N+1):
    fact *= i

s = 0
R = primes(N)
#print(R)
I = fact

soinsu = []
tmp = 1
cnt = 1
ans = 1
while s==0:
    for i in R:

        if I%i==0:
            I=I//i
            if I==1:
                s=1
#            soinsu.append(i)
            if i == tmp:
                cnt += 1
            else:
                ans *= (cnt + 1)
                ans %= mod
                cnt  = 1
                tmp = i
            break

#dic = collections.Counter(soinsu)
# ans = 1
# for v in dic.values():
#     ans *= v + 1
#     ans %= mod


print(ans)

Submission status: Accepted

Solution code:
n = int(input())
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,10000]

ass = []
m = 10**9+7
k = 0
while p[k] <= n:
    a = 0
    i = 1
    while p[k]**i <= n:
        a += (n//(p[k]**i))
        i += 1
    ass.append(a%m)
    k += 1
ans = 1
for i in range(len(ass)):
    ans = ans * (ass[i]+1) % m
print(ans)

Submission status: Accepted

Solution code:
import math

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

def primes(x):
    if x < 2: return []

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

    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
    
d = {}
P = primes(N + 1)

for p in P:
    d[p] = 0
    k = p
    while k <= N:
        d[p] += N // k
        k *= p

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

Submission status: Accepted

Solution code:
import math

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

def primes(x):
    if x < 2: return []

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

    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
    
d = {}
P = primes(N + 1)

for p in P:
    d[p] = 0
    k = p
    while k <= N:
        d[p] += N // k
        k *= p

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

Submission status: Accepted

Solution code:
n = int(input())
s = [2]
q = 1

for i in range(n+1):
	if i<3:
		continue
	t = []
	for j in range(len(s)):
		t.append((i)%s[j])
	if 0 in t:
		q = 3
	else:
		s.append(i)

x = 1

for i in range(len(s)):
	m = 0
	for j in range(10):
		m += n//(s[i]**(j+1))
	x *= m+1
print(x%(10**9+7))

Submission status: Accepted

Solution code:
N = int(input())
Prime = {}
mod = 7 + 10**9

if N > 2:
    Prime[2] = 1
    for i in range(3, N+1):
        M = i
        newPrime = True
        for j in Prime:
            if M % j == 0:
                newPrime = False
                while M % j == 0:
                    M //= j
                    Prime[j] += 1
        if newPrime:
            Prime[i] = 1
    
    ans = 1
    for p in Prime:
        ans *= Prime[p] + 1
        ans %= mod
    print(ans)

else:
    print(N)

Submission status: Accepted

Solution code:
num = int(input())
cnt_list = [0] * (num+1)
ans = 1

for i in range(2,num+1):
    x = i
    prime = 2
    while x > 1:
        while x%prime == 0:
            cnt_list[prime] += 1
            x = x//prime
        prime += 1

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

Submission status: Accepted

Solution code:
import math
N = int(input())
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
i = 2
primedic = {}
primelist = []#len = 168
while i <= 1000:
  if is_prime(i) == True:
    primedic[i] = 0
    primelist.append(i)
  i += 1
def usage(n):
    fct = factorize(n)
    return(fct)
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 num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
j = 2
while j <= N:
  li = usage(j)
  for array in li:
    primedic[array[0]] += array[1]
  j += 1
ans = 1
for keys in primedic:
  ans = (ans*(primedic[keys]+1))%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# primeFactorDecomposition(12): {2: 2, 3: 1}
def prime_factor_decomposition(n):
    import math
    m = defaultdict(int)
    while n > 1:
        find_factor = False
        for i in range(2, int(math.sqrt(n)) + 1):

            if n % i == 0:
                m[i] += 1
                n //= i
                find_factor = True
                break

        if not find_factor:
            m[n] += 1
            break

    return m


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

    d = defaultdict(int)
    for x in range(1, N + 1):
        p = prime_factor_decomposition(x)
        for k, v in p.items():
            d[k] += v

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = [i for i in range(1001)]
s[0] = 0
s[1] = 0
i = 2
while i < len(s):
    j = i * 2
    while s[i] != 0:
        if j >= len(s):
            break
        s[j] = 0
        j += i
    i += 1

N = int(input())
cnt = [0 for i in range(1001)]
for i in range(1, N + 1):
    j = 1
    while i != 1:
        while s[j] == 0:
            j += 1
        while i % j == 0:
            cnt[j] += 1
            i /= j
        j += 1
ans = 1
for i in s:
    if i != 0:
        ans *= cnt[i] + 1
print(ans % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
N=int(input())
def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = num**(0.5)

    for serial in range(3, num, 2):
        if serial >= sqrt:
            return input_list
        for s in range(serial ** 2, num, serial):
            input_list[s] = False

list=sieve_of_erastosthenes(max(N+1,6))
ans=1
for i in range(N+1):
    if list[i]:
        tmp=0
        M=N
        for t in range(1,10):
            if M//(i**t)==0:    break
            tmp+=M//(i**t)
        ans*=tmp+1
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
from math import sqrt,floor
MODN = int(1e9 +7)
N = int(input())

divnum = {}
if N==1:
  print(1)
  exit(0)
  
for i in range(1,N+1):
  work = i
  div = 2
  while work > 1:
    if work % div == 0:
      work = work // div
      if div in divnum:
        divnum[div] += 1
      else:
        divnum[div] = 1
    else:
      div += 1

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

Submission status: Accepted

Solution code:
N=int(input());q=1;t=[0]*N
for i in range(2,N+1):
    s=1
    while i>1:
        s+=1
        while i%s==0:
            i=i//s
            t[s-2]+=1
for j in range(N):
    q=q*(t[j]+1)%(10**9+7)
print(q)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def sieve(n):
    '''
    :param n:
    :return: n以下の素数のリストを返す
    エラトステネスの篩→O(n log log n)
    '''
    prime = []
    is_prime = [True] * (n + 1) #is_prime[i] = Trueならiは素数
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2 * i, n + 1, i):
                is_prime[j] = False
    return prime

N = int(input())
P = sieve(N)
ans = 1
for p in P:
    a = 0
    b = N // p
    while b > 0:
        a += b
        b //= p
    ans = ans * (a + 1) % (10 ** 9 + 7)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

dic = {}
ans = 1

def calc(N):
    n = N
    for i in range(2, N + 1):
        while n % i == 0:
            if i not in dic:
                dic[i] = 1
            else:
                dic[i] += 1
            n = int(n / i)

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

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

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

def factorize(n: int):
    d = Counter()
    m= 2
    
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
            
        m += 1
        
    if n > 1:
        d[n] += 1
        
    return d

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

fac = Counter()
for i in range(2,n+1):
    fac += factorize(i)
    
ans = 1
for k,v in fac.items():
    ans *= (v+1)
    ans %= MOD
    
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
list1=[]
for i in range(1001):
    list1.append(0)

for j in range(1,N+1):
    A=j
    for k in range(2,N+1):
        for l in range(11):
            if A%k==0:
                list1[k]+=1
                A=A/k
            else:
                break
ans=1
for m in range(1,len(list1)):
    if list1[m]==0:
        pass
    else:
        ans*=list1[m]+1
        if ans>=10**9+7:
            ans=ans%(10**9+7)
            
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

n = int(input())

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)

num = factorial(n)

ans = 1
for i in range(2, n+1):
    count = 0
    while num % i == 0:
        count += 1
        num = num // i
    ans *= (count + 1)

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

Submission status: Accepted

Solution code:

from math import sqrt
from collections import defaultdict 

# 半開区間[lower, upper)の素数のリストを作成する
def make_prime_list(lower:int, upper:int) -> list:
    
    # 変数のバリデーション
    if lower < 0:
        raise ValueError("lowerは0以上でなければいけません。(lower:{})".format(lower))

    elif upper <= lower:
        raise ValueError("upperはlowerより大きい数でなければいけません。\
                         (lower:{}, upper:{})".format(lower,upper))
    
    # 素数リストの初期化    
    isPrime = [True]*upper
    primeList = []
    
    # 区間内の数字が0,1のみならここで終了
    if upper <= 2:
        return primeList
    
    # 区間内の数字に2以上のものがあるとき
    isPrime[0] = False
    isPrime[1] = False
    
    # エラトステネスの篩の処理
    for n in range(2,int(sqrt(upper))+2):
        if isPrime[n]:
            res=2*n
            while res<upper:
                isPrime[res] = False
                res += n
    
    # 区間内の素数を抽出
    for n in range(lower,upper):
        if isPrime[n]:
            primeList.append(n)
        
    return primeList


# numを素因数分解する
def factoring(num: int, prime_list:list) -> dict:
    
    # バリデーション
    if num < 2:
        raise ValueError("numは2以上でなければいけません。(num:{})".format(num))
    
    
    # numまでの素数リストを作る
    prime_set = set(prime_list)
    
    # {素数: 含まれる数}の辞書を作る
    dic = defaultdict(int)
    res = num
    i = 0
    
    # resが素数になるまでdicに素因数を詰め続ける
    while not res in prime_set:
        if res % prime_list[i] == 0:
            dic[prime_list[i]] += 1
            res //= prime_list[i]
        
        else:
            i += 1
            if i >= len(prime_list):
                break
            
    dic[res] += 1
    
    return dic

# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())


MOD = 10**9 + 7
n = ni()

# nまでの素数リストを作る
prime_list = make_prime_list(0,n+1)

# 素因数の辞書
dic = defaultdict(int)
for num in range(2,n+1):
    fac = factoring(num, prime_list)
    for k,v in fac.items():
        dic[k] += v

# 約数は各素因数の数を+1して掛け算したもの
ans = 1
for v in dic.values():
    ans = ans*(v+1) % MOD
    
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())

def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

factors = Counter()

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

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

Submission status: Accepted

Solution code:
n=int(input())
x=[0 for i in range(2,1001)]
def soinsu(a):
    for i in range(2,a+1):
        t=0
        while(a%i==0):
            a/=i
            t+=1
        x[i-2]+=t
for i in range(2,n+1):
    soinsu(i)
a=1
for i in x:
    a*=i+1
    a%=10**9+7
print(a)

Submission status: Accepted

Solution code:
import math

n = int(input())
nmax = int(math.sqrt(n))
primes = [i for i in range(n+1)]
primes[0] = 0
primes[1] = 0
i = 2
while i <= n:
    if primes[i] == 0:
        i += 1
        continue
    for j in range(i*2,n+1,i):
        primes[j] = 0
    i += 1
    
primes = [i for i in range(n+1) if primes[i] != 0 ]
#print(primes)

primediv = [0]*len(primes)

for k in range(2,n+1):
    for j, p in enumerate(primes):
        cnt = 0
        while k % p == 0:
            cnt += 1
            k = k // p
        primediv[j] += cnt

ans = 1
for k in primediv:
    if k == 0:
        continue
    ans = (ans*(k+1))%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
Index=[0]*(N+1)
ans=1
Divider=pow(10,9)+7
for i in range(N+1):
    for j in range(i+1):
        if j>1:
            while i%j==0:
                i=int(i/j)
                Index[j]+=1
#print(Index)
for i in range(N+1):
    ans=ans*(Index[i]+1)%Divider
print(ans)

Submission status: Accepted

Solution code:
from math import sqrt
from collections import Counter

# 半開区間[lower, upper)の素数のリストを作成する
def make_prime_list(lower:int, upper:int) -> list:
    
    # 変数のバリデーション
    if lower < 0:
        raise ValueError("lowerは0以上でなければいけません。(lower:{})".format(lower))

    elif upper <= lower:
        raise ValueError("upperはlowerより大きい数でなければいけません。\
                         (lower:{}, upper:{})".format(lower,upper))
    
    # 素数リストの初期化    
    isPrime = [True]*upper
    primeList = []
    
    # 区間内の数字が0,1のみならここで終了
    if upper <= 2:
        return primeList
    
    # 区間内の数字に2以上のものがあるとき
    isPrime[0] = False
    isPrime[1] = False
    
    # エラトステネスの篩の処理
    for n in range(2,int(sqrt(upper))+2):
        if isPrime[n]:
            res=2*n
            while res<upper:
                isPrime[res] = False
                res += n
    
    # 区間内の素数を抽出
    for n in range(lower,upper):
        if isPrime[n]:
            primeList.append(n)
        
    return primeList


# numを素因数分解する
def factoring(num: int, prime_list: list) -> dict:
    
    # バリデーション
    if num < 2:
        raise ValueError("numは2以上でなければいけません。(num:{})".format(num))
    
    
    # numまでの素数リストを作る
    prime_set = set(prime_list)
    
    # {素数: 含まれる数}の辞書を作る
    cnt = Counter()
    res = num
    i = 0
    
    # resが素数になるまでdicに素因数を詰め続ける
    while not res in prime_set:
        if res % prime_list[i] == 0:
            cnt[prime_list[i]] += 1
            res //= prime_list[i]
        
        else:
            i += 1
            if i >= len(prime_list):
                break
            
    cnt[res] += 1
    
    return cnt


n = int(input())
prime_list = make_prime_list(0, n+1)
MOD = 10**9 + 7

cnt = Counter()
ans = 1
if n == 1:
    print(1)
    
else:
    # 素因数辞書作る
    for i in range(2,n+1):
        cnt += factoring(i, prime_list)

    # 掛け算する
    for k, v in cnt.items():
        ans = ans * (v+1) % MOD
        
    print(ans % MOD)

Submission status: Accepted

Solution code:
import math

N = int(input())

mod = 10 ** 9 + 7
count_dict = {}
ans = 1

def primes(x):
    if x < 2: 
        return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

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

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

def cal(n):
    global count_dict
    for i in count_dict.keys():
        if n % i == 0:
            count_dict[i] += 1
            n //= i
            return n

    

for i in primes(1000):
    count_dict[i] = count_dict.get(i-1, 0)

if N > 1:
    for i in range(2, N+1):
        while True:
            i = cal(i)
            if i == 1:
                break


for i in count_dict.values():
    if i != 0:
        ans *= (i+1)

print(ans % mod)

Submission status: Accepted

Solution code:
def generate(n):
    ans = []
    for i in range(2,n+1):
        flag = True
        for j in range(2,i):
            if(i%j == 0):
                flag = False
        if flag:
            ans.append(i)
    return ans

def factorial(n):
    ans = 1
    for i in range(1,n+1):
        ans *= i
    return ans

ans = 1
N = int(input())
l = generate(N)
N = factorial(N)
for p in l:
    q = 1
    while(N%p == 0):
        q += 1
        N = N // p
    ans *= q
print(ans%1000000007)

Submission status: Accepted

Solution code:
def generate(n):
    ans = []
    for i in range(2,n+1):
        flag = True
        for j in range(2,i):
            if(i%j == 0):
                flag = False
        if flag:
            ans.append(i)
    return ans

def factorial(n):
    ans = 1
    for i in range(1,n+1):
        ans *= i
    return ans

ans = 1
N = int(input())
l = generate(N)
N = factorial(N)
for p in l:
    q = 1
    while(N%p == 0):
        q += 1
        N = N // p
    ans *= q
    ans %= 1000000007
print(ans)

Submission status: Accepted

Solution code:
import math
def factor(x):
    for i in range(2, x+1):
        count = 0
        while x % i == 0:
            x = x / i
            count = count + 1
        else:
            L[i - 1] = L[i - 1] + count
N = int(input())
L = [0] * N
for i in range(1, N):
    factor(i+1)
M = 1
for i in range(N):
    M = M * (L[i]+1)
print(M % (10 ** 9 +7))

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

primes = [i for i in range(2, 10**3 + 1) if is_prime(i)]
end = len(primes)
def pfac(n):
    i = 0
    pfacts = []
    while i < end:
        if n % primes[i] == 0:
            n //= primes[i]
            pfacts.append(primes[i])
        else:
            i += 1
    return pfacts

n = int(input())
counts = {}
for i in range(2, n + 1):
    for p in pfac(i):
        counts[p] = counts.get(p, 0) + 1

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

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
from collections import Counter
import math

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

def main():
    n = int(input())
    arry = prime_factors(math.factorial(n))
    counter = Counter(arry)
    ans = 1
    for i in set(arry):
        ans *= (counter[i] + 1)
    print(ans % (10 ** 9 + 7))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

# input
N = int(input())

# エラトステネスの篩で素数を列挙（table[q] = 0: qは素数, table[i] = j: iはjを素因数に持つ）
def prime_factor_table(n):
    table = [0] * (n + 1)
    
    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i
    
    return table

def prime_factor(n, prime_factor_table):
    prime_count = dict()

    while prime_factor_table[n] != 0:
        if prime_factor_table[n] in prime_count.keys():
            prime_count[prime_factor_table[n]] += 1
        else:
            prime_count[prime_factor_table[n]] = 1
        n = int(n/prime_factor_table[n])
    if n in prime_count.keys():
        prime_count[n] += 1
    else:
        prime_count[n] = 1
    return prime_count

Ps = dict()
P_1000 = prime_factor_table(1000)
ans = 1

for i in range(2, N + 1):
    P_i = prime_factor(i, P_1000)
    for k in P_i.keys():
        if k in Ps.keys():
            Ps[k] += P_i[k]
        else:
            Ps[k] = P_i[k]

for k in Ps.keys():
    ans = (ans * (Ps[k] + 1)) % (10 ** 9 + 7)

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
n=int(input())
l=[]

for j in range(2,n+1):
  b=j
  for i in range(2,j+1):
    while not b%i:
      l.extend([i])
      b//=i
o=Counter(l)
p=int(1e9+7)
if n!=1:
  v=reduce(lambda x,y:x*y,map(lambda x:x+1,o.values()))%p
else:
  v=1
print(v)

Submission status: Accepted

Solution code:
n = int(input())

def isprime(num):
    if num == 1:
        return False
    if num == 2:
        return True
    elif num == 3:
        return True
    elif num % 2 == 0:
        return False
    elif num % 3 == 0:
        return False
    else:
        for i in range(5, int(num ** (1/2))+1):
            if num % i == 0:
                return False
                break
        return True

def prime_factor(num, prime_dict):
    if num == 1:
        return prime_dict
    if isprime(num):
        prime_dict[num] += 1
        return prime_dict
    if num % 2 == 0:
        prime_dict[2] += 1
        return prime_factor(num // 2, prime_dict)
    elif num % 3 == 0:
        prime_dict[3] += 1
        return prime_factor(num // 3, prime_dict)
    else:
        for i in range(5, int(num ** (1/2))+1):
            if num % i == 0:
                prime_dict[i] += 1
                return prime_factor(num // i, prime_dict)

prime_dict = {}
for i in range(1, n+1):
    if isprime(i):
        prime_dict[i] = 0

for i in range(1, n+1):
    prime_dict = prime_factor(i, prime_dict)

result = 1
for value in prime_dict.values():
    result *= value+1
    if result > 1000000007:
        result = divmod(result, 1000000007)[1]

print(result)

Submission status: Accepted

Solution code:
n = int(input())
m = 10**9+7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*1001

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

score = 1
for d in D:
    score = (score * (d + 1)) % m
print(score)

Submission status: Accepted

Solution code:
def prime_table(n):
    rng = range(2, n + 1)
    tbl = [False] + [False] + [True for _ in rng]
    for i in rng:
        j = i + i
        if tbl[i]:
            while j < len(tbl):
                tbl[j] = False
                j += i
    ret = [i for i in range(n + 1) if tbl[i]]
    return ret

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

ans = 1
for p in prime_table(n):
    power = 1
    buf = 0
    while True:
        p_cnt = n // (p ** power)
        if p_cnt == 0:
            break
        buf += p_cnt
        power += 1
    ans *= (buf + 1)
    if ans > d:
        ans %= d
print(ans)

Submission status: Accepted

Solution code:
MOD = 10**9+7

n = int(input())

def get_primes(n_max):
    count = 0
    ps = [2, 3]

    for n in range(5, n_max+1, 2):
        is_p = True
        for i in range(1, len(ps)):
            count += 1
            if ps[i]**2 > n:
                break
            count += 1
            if n%ps[i] == 0:
                is_p = False
                break
        if is_p:
            ps.append(n)
    return ps
            
primes = get_primes(n)
p_dict = dict(zip(primes, [0]*len(primes)))
ns = [i for i in range(n+1)]
for i in range(2, n+1):
    p = ns[i]
    if p == 1: continue
    p_dict[p] += n//i
    for j in range(i, n+1, i):
        ns[j] = ns[j]//p

# print(p_dict)
ans = 1
for key, item in p_dict.items():
    ans = ans*(item+1)%MOD
print(ans)

Submission status: Accepted

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

import math

# 階乗しないで求める版
# 素数数え上げないで計算する版

x = int(input())

# 素数判定用関数
def is_prime_2(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

# xまでの間にある素数を列挙
sosu_list = []
for i in range(x+1):
    if is_prime_2(i):
        sosu_list.append(i)

# 各素数毎に、数え上げないで計算する
sosu_cnt = {}
for sosu in sosu_list:
    i = sosu
    while i <= x:
        if sosu in sosu_cnt:
            sosu_cnt[sosu] += x // i
        else:
            sosu_cnt[sosu] = x // i
        i *= sosu

# 素数カウントを使って、約数の個数を求める
ans = 1
for key, value in sosu_cnt.items():
    sosu_cnt[key] += 1
    ans = (ans * sosu_cnt[key]) % (10 ** 9 + 7)
print(ans)

Submission status: Accepted

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

import math

# 階乗しないで求める版

x = int(input())

# 素数判定用関数
def is_prime_2(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

# xまでの間にある素数を列挙
sosu_list = []
for i in range(x+1):
    if is_prime_2(i):
        sosu_list.append(i)

# 素数のカウントは階乗前の値から個別に取って合算でも問題ない
sosu_cnt = {}
for i in range(1, x+1):
    for sosu in sosu_list:
        while i % sosu == 0:
            if sosu in sosu_cnt:
                sosu_cnt[sosu] += 1
            else:
                sosu_cnt[sosu] = 1
            i //= sosu

# 素数カウントを使って、約数の個数を求める
ans = 1
for key, value in sosu_cnt.items():
    sosu_cnt[key] += 1
    ans = (ans * sosu_cnt[key]) % (10 ** 9 + 7)
print(ans)

Submission status: Accepted

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

import math

x = int(input())

# 階乗
a = math.factorial(x)

# 素数判定用関数
def is_prime_2(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

# xまでの間にある素数を列挙
sosu_list = []
for i in range(x+1):
    if is_prime_2(i):
        sosu_list.append(i)

# 素因数分解していく中で、使った素数のカウントを取る
sosu_cnt = {}
for sosu in sosu_list:
    while a % sosu == 0:
        if sosu in sosu_cnt:
            sosu_cnt[sosu] += 1
        else:
            sosu_cnt[sosu] = 1
        a //= sosu

# 素数カウントを使って、約数の個数を求める
ans = 1
for key, value in sosu_cnt.items():
    sosu_cnt[key] += 1
    ans = (ans * sosu_cnt[key]) % (10 ** 9 + 7)
print(ans)