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 sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
from functools import partial, reduce
from operator import mul
prod = partial(reduce, mul)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter
primes = list(range(1001))
primes[1] = 0
for i in range(2, int(1000 ** 0.5) + 1):
    if primes[i]:
        for j in range(2 * i, 1001, i):
            primes[j] = 0
primes = [p for p in primes if p != 0]

def main():
    N = II()
    primefactors = Counter()
    for n in range(1, N+1):
        for p in primes:
            if n == 1:
                break
            while n % p == 0:
                primefactors[p] += 1
                n //= p
    ans = reduce(lambda x, y: x * (y+1), primefactors.values(), 1) % MOD
    return ans

print(main())

Submission status: Accepted

Solution code:
thelist=[2]
for i in range(3,1000):
        t=0
        for j in range(2,i):
            if i%j==0:
                t=1
                continue
        if t==0:
            thelist.append(i)
while True:
    try:
        n=int(input())
    except:
        break
    thedic={}
    for i in thelist:
        thedic[i]=0
    for i in range(1,n+1):
        t=i
        j=0
        while j!=len(thelist):
            if t%thelist[j]==0:
                thedic[thelist[j]]+=1
                t=t/thelist[j]
                continue
            j=j+1
            if t==1:
                break
    value=1
    for i in thedic:
        value=value%(1000000000+7)*(thedic[i]+1)
    print(value%(1000000000+7))

Submission status: Accepted

Solution code:
def prime(N):
    p = 2
    koko = int(N**0.5)
    while N != 1:
        if N % p == 0:
            yaku[p] += 1
            N //= p
        elif p > koko:
            p = N
        else:
            p += 1
    return


N = int(input())

ans = 0
mod = 10**9 + 7
yaku = [0 for i in range(10**3)]
for i in range(1, N + 1):
    prime(i)

ans = 1
for a in yaku:
    ans *= a + 1
print(ans % mod)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/
Solved on 2019/2/
@author: shinjisu
"""


# ARC 067 C Factors of Factorial
import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def getDivisor(n):
    div = []
    for i in range(2, n+1):
        if n % i == 0:
            div.append(i)
    return div


# n以下の素数を求める - エラトステネスのふるい
def getPrime(n):
    prime = [2]
    num = [i for i in range(3, n+1, 2)]
    while num != []:
        p = num.pop(0)  # 先頭は素数
        prime.append(p)
        for a in num:  # 素数で割り切れる数を除去
            if a % p == 0:
                num.remove(a)
    return prime


# 素因数分解する
def getPrimeFactor(n):
    if n <= 1:
        return [1], [1]
    prime = getPrime(n)
    factor = []
    power = []
    for a in prime:
        pw = 0
        while n % a == 0:
            pw += 1
            n //= a
        if pw > 0:
            factor.append(a)
            power.append(pw)
    return factor, power


def probC():
    N = getInt()
    dmp(N)
    divisor = zeros(N+1)
    for i in range(2, N+1):
        factor, power = getPrimeFactor(i)
        dmp((factor,power), 'factor,power')
        for j in range(len(factor)):
            divisor[factor[j]] += power[j]
    dmp(divisor)
    divCount = 1
    for i in range(2, N+1):
        divCount = divCount * (divisor[i]+1) % N1097
    return divCount


debug = False  # True False
ans = probC()
print(ans)
#for row in ans:
#    print(row)


"""
def getPrimeOld(n):
    prime = [2]
    num = [i for i in range(3, n+1, 2)]
    num.reverse()
    while num != []:
        p = num.pop()  # 末尾は素数
        prime.append(p)
        for a in num:  # 素数で割り切れる数を除去
            if a % p == 0:
                num.remove(a)
    return prime
"""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
query = [0]*1001
mod = 10**9+7
tmp = n
for tmp in range(1,n+1):
 for i in range(2,1002):
  while tmp%i == 0:
   query[i-1] += 1
   tmp = tmp//i
ans = 1
for i in query:
  ans= ans*(1+i)%mod
print(ans%mod)

Submission status: Accepted

Solution code:
from functools import reduce


def primes_list(N):
    l = [v for v in range(2, N+1)]
    ret = []
    while l:
        cur = l.pop(0)
        l = list(filter(lambda x: x % cur != 0, l))
        ret.append(cur)
    return ret


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

l = [0]*(N+1)
primes = primes_list(N)

for i in range(2, N+1):
    for p in primes:
        if p > i:
            break
        tmp = 0
        while i % p == 0:
            i //= p
            tmp += 1
        l[p] += tmp

ans = 1
for i in l:
    if i == 0:
        continue
    else:
        ans = ans*(i+1) % mod
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

def trial_division(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)
    #Only odd number is possible
    return a

N = int(input())
D = {}
for i in range(1,N+1) :
    C = dict(Counter(trial_division(i)))
    for j in C :
        if j not in D :
            D[j] = C[j]
        else :
            D[j] += C[j]
ans = 1
for i in D.values() :
    i %= 10**9+7
    ans *= i+1
    ans %= 10**9+7
print(ans)
#print(D)

Submission status: Accepted

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


def solve(m: int):
    from math import sqrt

    ans = dict()
    remain = m

    for j in range(2, int(sqrt(m)) + 1):
        if remain % j == 0:
            count = 0

            while remain % j == 0:
                count += 1
                remain //= j

            ans[j] = count

    if remain != 1:
        ans[remain] = 1

    return ans


def main():
    n = int(input())
    d = dict()
    mod = 10 ** 9 + 7
    ans = 1

    for i in range(2, n + 1):
        new = solve(i)

        for key, value in new.items():
            if key not in d.keys():
                d[key] = value
            else:
                d[key] += value

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
MOD = 10**9 + 7


def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


N = int(input())
if N == 1:
    print(1)
    exit()
N_list = seachPrimeNum(N)
ans_list = [0 for i in range(len(N_list))]
for i in range(2, N+1):
    temp_i = i
    for j in range(len(N_list)):
        while temp_i % N_list[j] == 0:
            temp_i = temp_i // N_list[j]
            ans_list[j] += 1
ans = 1
for i in range(len(ans_list)):
    ans = ans * (ans_list[i]+1) % MOD
print(ans)

Submission status: Accepted

Solution code:
from math import factorial

n = factorial(int(input()))
cnt = 2
k = 1
ans = 1

while n != 1:
    if n % cnt == 0:
        n //= cnt
        k = k + 1
    else:
        ans = ans * k
        k = 1
        cnt += 1
anw = (ans * k) % (10**9 + 7)
print(anw)

Submission status: Accepted

Solution code:
N = int(input())
MOD = int(1e+9) +7 
prime = [2]

for i in range(2,1001):
    for j in range(2, i-1):
        if i % j == 0:
            break
    else:
        prime.append(i)

factor = [1] * 1000

for i in range(1, N+1):
    for p in prime:
        if i == 1:
            break
        while i % p == 0:
            i /= p 
            factor[p] += 1

ans = 1
for fact in factor:
    ans *= fact
    ans %= MOD
print(int(ans))

Submission status: Accepted

Solution code:
mod = 10**9+7
def hmf(n, k, k1):
    x = n//k
    if not x:
        return 0
    return x + hmf(n, k*k1, k1)

primes = [i for i in range(10**3+1)]
primes[1] = 0 

for p in primes:
    if p > int(10**(3/2)): break
    if p == 0: continue
    for non_prime in range(2 * p, 10**3+1, p): 
        primes[non_prime] = 0
    prime = [prime for prime in primes if prime != 0]

N = int(input())
ans = 1
for p in prime:
    c = hmf(N, p, p)
    if not c:
        break
    ans = ans*(1+hmf(N, p, p))%mod
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n < 3:
    print(n)
    exit()

primes = [2]

import math
for i in range(3, n+1):
    k = int(math.sqrt(i))
    flag = True
    for p in primes:
        if p > k:
            break
        if  i%p == 0:
            flag = False
            break
    if flag:
        primes.append(i)

ans = 1
for p in primes:
    k = n
    cnt = 0
    while k:
        k = k//p
        cnt += k
    # print(p, cnt)
    ans *= cnt + 1
ans = ans % (10**9 + 7)
print(ans)

Submission status: Accepted

Solution code:
N=int(input().strip())
flis=[0]*1001
inf=(10**9)+7
def fact(n):
    global flis
    for i in range(2,n+1):
        while n%i==0:
            n=n//i
            flis[i]+=1


def solve(n):
    ans=1
    for i in range(1,n+1):
        fact(i)
    for i in range(1,n+1):
        ans*=(flis[i]+1)
    return ans

print(solve(N)%inf)

Submission status: Accepted

Solution code:
import sys
import collections
import math
from collections import Counter
from collections import deque

N = int(input())

d = 10**9 + 7


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


cnt = Counter()

for i in range(2, N + 1):
    prime_list = prime_decomposition(i)
    tmpCnt = Counter(prime_list)
    cnt.update(tmpCnt)

# print(cnt)

ans = 1
for i in cnt.items():
    ans *= (i[1] + 1)

print(ans % d)

sys.exit(0)

Submission status: Accepted

Solution code:
n = int(input())
from collections import defaultdict
d = defaultdict(int)
mod = 1000000007
for i in range(2,n+1):
  for j in range(2,i+1):
    while i%j ==0 and i != 0:
      d[j] += 1
      i//=j
ans = 1
for i in d.values():
  ans *= (i+1)
  ans %= mod
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
list1=[1 for i in range(N+1)]

for i in range(1,N+1):
    X=i
    for j in range(2,N+1):
        while X%j==0:
            if X==0:
                pass
            elif X%j==0:
                list1[j]+=1
                X=X/j
ans=1   
for k in range(len(list1)):
    ans*=list1[k]
    #ans=ans%1000000007
print(ans%1000000007)

Submission status: Accepted

Solution code:
import math

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

N = int(input())


for i in range(1,N + 1):
	L = []
	if i == 1:
		pass
	elif i == 2:
		LL[2] += 1
	else:
		n = int(math.sqrt(N) // 1)
		x = 2
		for j in range(n + 2):
			while True:
				if i % x == 0:
					L.append(x)
					i = int(i // x)
				else:
					break
			x += 1
		if i != 1:
			L.append(i)
	for j in L:
		LL[j] += 1


ans = 1
for i in LL:
	if i == 0:
		pass
	else:
		ans = ans * (i + 1)
		ans = ans % 1000000007

print(ans)

Submission status: Accepted

Solution code:
def prime(n):
    p_list=[2]
    for i in range(3,n+1):
        flag=True
        for p in p_list:
            if i%p==0:
                flag=False
                break
        if flag:
            p_list.append(i)
    return p_list
    
p_list=prime(1000)
N=int(raw_input())
p_count = [1 for i in range(len(p_list))]
for i in range(len(p_list)):
    j=1
    p=p_list[i]
    count=0
    while p**j <=N:
        count+=int(N/(p**j))
        j+=1
    p_count[i]+=count

ans=1
for c in p_count:
    ans= (ans*c)%(10**9+7)
print ans

Submission status: Accepted

Solution code:
S=int(input());
s=[];
x=[];
X=[];
so=[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];
ans=1;
for h in range(S):
    Y=h+1;
    for i in so:
        j=0;
        while Y%i==0:
            Y=Y/i;
            s=s+[i];
            j+=1;
for i in so:
    x=x+[s.count(i)];
X=[X+1 for X in x];
for i in X:
    ans=ans*i;
print(ans%1000000007);

Submission status: Accepted

Solution code:
import math
def prime(n): # nまでの素数を列挙
    import math
    if n == 1:
        return []
    else:
        num_list = [i + 1 for i in range(2,n,2)]
        list_prime = [2]
        limit = math.sqrt(n)
        if n == 2:
            return list_prime
        else:
            while True:
                p = num_list[0]
                if p >= limit:
                    return list_prime + num_list
                list_prime.append(p)
                num_list = [num for num in num_list if num % p != 0]

def primeFactorization(n):
    if n == 1:
        return {}
    list_prime = prime(int(x))
    i = 0
    dict_pF = {}
    dict_primeFactorization = {}
    for pri in list_prime:
        dict_pF[pri] = 0
    while True:
        if n == 1:
            for key, value in dict_pF.items():
                if value != 0:
                    dict_primeFactorization[key] = value
            return dict_primeFactorization
        elif i >= len(list_prime):
            dict_pF[n] = 1
            for key, value in dict_pF.items():
                if value != 0:
                    dict_primeFactorization[key] = value
            return dict_primeFactorization
        p = list_prime[i]
        if n % p == 0:
            n //= p
            dict_pF[p] += 1
            continue
        else:
            i += 1


x = int(input())
ans_dict = primeFactorization(math.factorial(x))
ans = 1
for value in ans_dict.values():
    ans *= value+1
print(ans%(10**9 + 7))

Submission status: Accepted

Solution code:
import math

MOD = 10 ** 9 + 7

def factorizec(n):
    fct = []
    b = 2
    e = 0
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b, e))
        b += 1
        e = 0
    if n > 1:
        fct.append((n, 1))
    return fct

n = int(input())
fct = factorizec(math.factorial(n))
ans = 1
for i in fct:
    ans *= (i[1] + 1) % MOD
print(ans % MOD)

Submission status: Accepted

Solution code:
# Factors of Factorial

import math
from collections import defaultdict

def primes(n): # Eratosthenes' sieve
    prime = [True] * (n + 1)
    prime[0] = False
    prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            prime[j] = False
    return [i for i in range(n + 1) if prime[i]]
        
def factorize(n):
    result = defaultdict(int)
    for p in primes(n):
        while n % p == 0:
            n = n // p
            result[p] += 1
    return result

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
lis = [0 for i in range(n)]
for i in range(2,n+1):
  cou = 2
  while i >= cou:
    if i % cou == 0:
      lis[cou-1] += 1
      i //= cou
    else:
      cou += 1
cou = 1
for i in range(len(lis)):
  cou *= (lis[i]+1)
  cou %= (10 ** 9+7)
print(cou)

Submission status: Accepted

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N = input()
div = [1] * 1100

for i in range(N):
    num = i + 1
    for den in range(2, 1000):
        while num % den == 0:
            num /= den
            div[den] += 1

ans = 1
MOD = 10 ** 9 + 7
for num in div:
    ans *= num
    ans %= MOD
print ans

Submission status: Accepted

Solution code:
import math


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 [p for p in primes if p != 0]


N = int(input())
ans = 1
for p in primes(N+1):
    k = 0
    for n in range(1,N+1):
        while n%p==0:
            n /= p
            k += 1
    ans *= k+1
    ans %= 1000000007
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
MOD = 10**9 + 7

d = {}
for i in range(2,n+1):
    for j in range(2,i+1):
        while i%j==0:
            if j not in d:
                d[j] = 1
            d[j] += 1
            i = i//j
ret = 1
for v in d.values():
    ret = (ret*v)%MOD
print(ret)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys
class Prime:
    def __init__(self,number):#N以下の素数
        self.jud=[True]*(number+5)
        self.pri=[]
        self.jud[0]=False
        self.jud[1]=False
        for i in range(number):
            if self.jud[i]:
                self.pri.append(i)
                for j in range(2,(number)//i+1):
                    self.jud[i*j]=False
    
    def judge(self,x):
        return self.jud[x]
    
    def decom(self,x):
        s=x
        a =defaultdict(int)
        if s==1:
            return a
        while s>1:
            for p in self.pri:
                if s%p==0:
                    a[p]+=1
                    s=s//p
                    break
        return a
            
N=int(input())
mod=10**9+7
if N==1:
    print(1)
    sys.exit()
A=Prime(10**3+1)
dd=defaultdict(int)
for i in range(2,N+1):
    for p,j in A.decom(i).items():
        dd[p]+=j
ans=1
for j in dd.values():
    ans*=j+1
    ans%=mod
print(ans)

Submission status: Accepted

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

for i in range(1,n+1):
    b = 2
    while i > 1:
        if i % b == 0:
            if b in a:
                a[b] += 1
            else:
                a[b] = 1
            i = i//b
        else:
            b += 1
ans = 1
for i in a:
    ans *= a[i]+1
print(ans%1000000007)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
prime = [2]
flag = 1
for i in range(3,1000):
    for j in prime:
        if i % j == 0:
            flag = 0
            break
    if flag == 1:
        prime.append(i)
    flag = 1
N = int(input())
ans = 1
mod = 10**9+7
kosu = [0]*1000
for i in prime:
    for j in range(1,N+1):
        hoge = j
        while hoge % i == 0:
            hoge /= i
            kosu[i] += 1
for i in kosu:
    ans *= (i+1)
    ans  = ans % mod
print(ans)

Submission status: Accepted

Solution code:
import math
from collections import Counter
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()
            
            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

mysum = math.factorial(n)

i = 2

if mysum==1:
    
    arr=[]

else:

    arr = []
    while i < mysum:

        if mysum % i == 0:

            arr.append(i)

            mysum = mysum // i

        else:

            i+=1

    else:

        arr.append(i)


list01=Counter(arr)

cnt=1
for k in list01:

    cnt *=list01[k]+1

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 1
mod = pow(10,9)+7

INSU = {}

#引用・改変：https://qiita.com/ym11235/items/fb01b2e84041bd2eaffd
import math
for j in range(2,N+1):
    I=j
    s=0
    R=int(I)
    L=[]
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
    if len(L)==1:
        #print(R ,"is a prime")
        INSU[R] = 1
    else:
        #print(L)
        for l in L: INSU[l] += 1
    ans = 1
    for insu in INSU:
        ans = (ans*(INSU[insu]+1))%mod
        
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(lambda:0)
for n in range(2,N+1):
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1

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

Submission status: Accepted

Solution code:
from collections import Counter
from math import sqrt
def fact(n):
    l = int(sqrt(n))
    a = []
    while not n%2:
        a.append(2)
        n //= 2
    for i in range(3,l+1,2):
        while not n%i:
            a.append(i)
            n //= i
    if n != 1:
        a.append(n)
    return Counter(a)


n = int(input())
c = Counter()
mod = 10**9 + 7
ans = 1
for j in range(1,n+1):
    c += fact(j)
for i in list(c.values()):
	ans = ans * (i+1)%mod
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
import math
import collections
mod=10**9+7
fac=math.factorial(n)
ans=[0]*(n+1)
ans[0]=ans[1]=1
i=2
while i*i<=n:
    j=2
    while i*j<=n and ans[i]==0:
        ans[i*j]=1
        j+=1
    i+=1
v=[]
for i in range(n+1):
    if ans[i]==0:
        v.append(i)
v.sort()
num=[]
for k in v:
    while fac%k==0:
        fac//=k
        num.append(k)
data=collections.Counter(num)
cnt=1
for i,j in data.items():
    cnt*=j+1
print(cnt%mod)

Submission status: Accepted

Solution code:
# coding: utf-8
n=int(input())
use=[0 for i in range(n+1)]
for i in range(1,n+1):
    for j in range(2,n+1):
        while i%j==0 and i!=1:
            i=i//j
            use[j]+=1
ans=1
for i in range(len(use)):
    if use[i]!=0:
        ans*=use[i]+1
print(ans%1000000007)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
from collections import Counter
N = int(input())


def f(n):
    temp = n
    c = Counter()
    for i in range(2, n):
        if temp == 1:
            break
        while temp%i == 0:
            temp = temp//i
            c.update([i])
    else:
        c.update([temp])
    return c

c = Counter()
for i in range(2, N+1):
    c.update(f(i))

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

prime = [True] * 1001
prime[0] = prime[1] = False
primes = []
for i in range(2, 1001):
  if prime[i]:
    primes.append(i)
    for j in range(i*i, 1001, i):
      prime[j] = False

soinsuu = {}
for i in range(1, N+1):
  x = i
  for p in primes:
    while x % p == 0:
      soinsuu[p] = soinsuu.get(p, 0) + 1
      x //= p

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

Submission status: Accepted

Solution code:
N = int(input())

fs = [0] * N
for i in range(2, N + 1):
    d = 2
    while i > 1:
        if i % d == 0:
            fs[d - 1] += 1
            i //= d
        else:
            d += 1

MOD = 10 ** 9 + 7
ans = 1
for f in fs:
    ans *= (f + 1)
    ans %= MOD

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from functools import reduce
from operator import mul
def inpl(): return list(map(int, input().split()))
 
def primes(max_number):
    if max_number <= 2:
        raise StopIteration
    yield 2
    is_prime = [1] * max_number
    square_root_of_max = max_number ** 0.5
    for number in range(3, max_number, 2):
        if is_prime[number] is 0:
            continue
        yield number
        if number <= square_root_of_max:
            for multiple in range(number * 2, max_number, number):
                is_prime[multiple] = 0

N = int(input())
P = tuple(primes(10**3))
D = {k:1 for k in P}

for p in P:
    tmp = p
    while True:
        if tmp > N:
            break
        else:
            D[p] += N//tmp
        tmp *= p

print(reduce(mul, D.values())%(10**9+7))

Submission status: Accepted

Solution code:
from collections import defaultdict

MOD = 1000000007


def prime_generator(limit):
    yield 2
    n, h = 3, {}
    while n <= limit:
        m = n
        if n in h:
            b = h[n]
            m += 2 * b
            while m in h:
                m += 2 * b
            h[m] = b
            del h[n]
        else:
            m += 2 * n
            while m in h:
                m += 2 * n
            h[m] = n
            yield n
        n += 2


def solve(n):
    ps = list(prime_generator(n))
    factors = defaultdict(int)
    for i in range(1, n):
        k = i + 1
        for p in ps:
            while k % p == 0:
                k //= p
                factors[p] += 1
            if k == 1:
                break

    ans = 1
    for c in factors.values():
        ans *= c + 1
        ans %= MOD
    return ans


print(solve(int(input())))

Submission status: Accepted

Solution code:
from collections import defaultdict

MOD = 1000000007


def prime_generator(limit):
    yield 2
    n, h = 3, {}
    while n <= limit:
        m = n
        if n in h:
            b = h[n]
            m += 2 * b
            while m in h:
                m += 2 * b
            h[m] = b
            del h[n]
        else:
            m += 2 * n
            while m in h:
                m += 2 * n
            h[m] = n
            yield n
        n += 2


def solve(n):
    ps = list(prime_generator(n))
    prev = defaultdict(int)
    for i in range(1, n):
        f = prev.copy()
        k = i + 1
        for p in ps:
            while k % p == 0:
                k //= p
                f[p] += 1
            if k == 1:
                break
        prev = f

    ans = 1
    for c in prev.values():
        ans *= c + 1
        ans %= MOD
    return ans


print(solve(int(input())))

Submission status: Accepted

Solution code:
n = int(raw_input())
mod = 10**9 + 7
prime = [True for i in range(n + 1)]

res = 1
for i in range(2, n + 1):
	if prime[i]:
		curr = i * i
		while curr <= n:
			prime[curr] = False
			curr += i

		curr = i
		exponent = 0

		while curr <= n:
			exponent += n / curr
			curr *= i

		res *= (exponent + 1)
		res %= mod

print res

Submission status: Accepted

Solution code:
import numpy
mod=10**9+7
def primesfrom2to(n):
    """, Returns a array of primes, 2 <= p < n """
    if n==1:return numpy.array([])
    if n==2:return numpy.array([])
    if n==3:return numpy.array([2])
    if n==4:return numpy.array([2,3])
    if n==5:return numpy.array([2,3])
    sieve = numpy.ones(n//3 + (n%6==2), dtype=numpy.bool)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[       k*k//3     ::2*k] = False
            sieve[k*(k-2*(i&1)+4)//3::2*k] = False
    return numpy.r_[2,3,((3*numpy.nonzero(sieve)[0][1:]+1)|1)]
n=int(input())
table=[]
for i in primesfrom2to(n+1):
    i=int(i)
    cnt=0
    originalp=i
    p=originalp
    while True:
        tmp=n//p
        if tmp==0:
            break
        else:
            p*=originalp
            cnt+=tmp
    table.append(cnt)
ans=1
#print(table)
for i in table:
    ans=(ans*(i+1))%mod
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def eratos(n):
    if n <= 1:
        return []
    used = [False] * n
    used[0] = used[1] = True
    primes = []
    for i in range(n):
        if used[i] is False:
            primes.append(i)
            for j in range(i * 2, n, i):
                used[j] = True
    return primes


n = int(input())
primes = eratos(n + 1)
primes_dict = defaultdict(lambda: zip(primes, [1] * len(primes)))
X = n
d = 2
defactors = defaultdict(int)

for i in range(2, n + 1):
    if primes_dict[i] == 1:
        defactors[i] += 1
        continue

    for prime in primes:
        if i == 1:
            continue
        while i % prime == 0:
            defactors[prime] += 1
            i //= prime

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

Submission status: Accepted

Solution code:
primes = [2]

MOD = 10**9 + 7
def isPrime(n):
    if n % 2 == 0 or n < 2:
        return False
    for i in range(3,int(n/2)):
        if n % i == 0:
            return False
    return True

for i in range(3,1000,2):
    if isPrime(i):
        primes.append(i)


N = int(input())
factors = [[0 for j in range(N)] for i in range(len(primes))]

for i in range(N):
    j = i+1
    tmp = j
    a = 0
    while primes[a] <= tmp:
        if tmp % primes[a] == 0:
            factors[a][i] += 1
            tmp /= primes[a]
        else:
            a += 1
l = [sum(t) for t in factors]
ans = 1
for i in l:
    ans *= i+1
print(ans % MOD)

Submission status: Accepted

Solution code:
import collections
MOD = 10**9+7
def list_prime(n):
    if n < 2:
        return []
    elif n == 2:
        return [2]
    is_prime = [True for i in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n):
        for j in range(i*i, n+1, i):
            is_prime[j] = False
    prime = []
    for i in range(n+1):
        if is_prime[i]:
            prime.append(i)
    return prime

def cnt_factor(n, p):
    cnt = 0
    pi = p
    while pi <= n:
        cnt += n //pi
        pi *= p
    return cnt

n = int(input())
p_list = list_prime(n)
cnt = 1
for p in p_list:
    cnt = cnt * (cnt_factor(n, p)+1) % MOD
print(cnt)