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
mod = 10 ** 9 + 7
N = int(input())
if N == 1:
  print(1)
  quit()

prime = []
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  

for i in range(1, 1001):
  if is_prime(i):
    prime.append(i)
#print(prime)
x = len(prime)  
  
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = [0] * x
#print(factorization(24))#[[2, 3], [3, 1]]
for i in range(2, N + 1):
  now = factorization(i)
  for j in range(len(now)):
    index = prime.index(now[j][0])
    ans[index] += now[j][1]
  
answer = 1  
for i in range(x):
  if ans[i] != 0:
    answer *= (ans[i] + 1) 
    answer = answer % mod
#print(ans)
print(answer % mod)

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
    def factorization(num):
        result = []
        count = 0
        temp = num
        for i in range(2, int(num ** 0.5) + 1):
            if temp % i == 0:
                count = 0
                while temp % i == 0:
                    count += 1
                    temp /= i
                result.append([i, count])
        if temp != 1:
            result.append([int(temp), 1])
        if result == []:
            result.append([num, 1])
        return result
    n = int(input())
    d = defaultdict(int)
    mod = 1000000007
    if n == 1:
        print(1)
        exit()
    for i in range(2, n + 1):
        res = factorization(i)
        for (f, v) in res:
            d[f] += v
    ans = 1
    for v in d.values():
        ans = ans * (v + 1) % mod
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
mod = int(1e9+7)
cnt = 1

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

fd = dict()
for i in range(2, n+1):
    f = factorization(i)
    for j in f:
        if j[0] not in fd:
            fd[j[0]] = j[1]
        else:
            fd[j[0]] += j[1]
fd = list(fd.values())
for i in fd:
    cnt *= i+1
    cnt %= mod
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np
MOD = 1000000007
n = int(input())

cnt = np.ones(n+1)

for i in range(2, n+1):
    m = i
    for j in range(2, i+1):
        while m % j == 0:
            m = m / j
            cnt[j] += 1
ans = 1
for i in range(2, n+1):
    ans = (ans * cnt[i]) % MOD
print(int(ans))

Submission status: Accepted

Solution code:
import math
n = int(input())
mod = 10**9 +7
ans = 1
k = 1
i = 2
N = math.factorial(n)

while N != 1:
    if N%i == 0:
        N = N//i
        k += 1
    else:
        ans *= k
        k = 1
        i += 1
ans *= k
print(ans%mod)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
factors = []
for i in range(N):
    T = N-i
    d = 2
    while d**2<=T:
        if T%d==0:
            factors.append(d)
            T//=d
        else:
            d+=1
    if T!=1:
        factors.append(T)
factors = Counter(factors)
ans = 1
for v in factors.values():
    ans *= (v+1)
mod = 10**9 +7
print(ans%mod)

Submission status: Accepted

Solution code:
import math

def factorize(n):
    d = {}
    temp = int(math.sqrt(n))+1
    for i in range(2, temp):
        while n%i== 0:
            n //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[n] = 1
    else:
        if n in d:
            d[n] += 1
        elif n != 1:
            d[n] =1
    return d

n = int(input())

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

mod = 10**9+7
D = {}
for i in range(2, n+1):
    d = factorize(i)
    for k, v in d.items():
        if k not in D:
            D[k] = v
        else:
            D[k] += v
ans = 1
for v in D.values():
    ans *= (v+1)
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
m = math.factorial(N)
arr = 1000*[1]

for n in range(2,1001):
  while m%n==0:
    m//=n
    arr[n]+=1

ans = 1
for n in arr:
  ans*=n

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
li = []
for k in range(2, n+1):
  for i in range(2, int(k**0.5)+1):
    while k % i == 0:
      k //= i
      li.append(i)
  if k != 1:
    li.append(k)
c = collections.Counter(li)
ans = 1
for k, v in c.items():
  ans *= (v+1)
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())

def isprime(n):
	if n == 1:
		return False
	for i in range(2, int(n**0.5)+1):
		if n % i == 0:
			return False
	return True

ansl = []

for i in range(1, n+1):
	if isprime(i):
		tmp = 1
		tmpans = 0
		while True:
			youso = n // (i**tmp)
			tmpans += youso
			if youso == 0:
				break
			tmp += 1
		ansl.append(tmpans)

ans = 1
mod = 10**9+7

for i in ansl:
	ans = ans * (i+1) % mod

print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    #f(x):=x以下の素数を列挙する関数
    #int -> list
    def f(x):
        if x < 2:
            return [] 
        res = [2]
        for i in range(2, x+1):
            f = True
            for j in res:
                if i%j == 0:
                    f = False
            if f:
                res.append(i)
        return res
    primes = f(n)
    numOfPrime = []
    for p in primes:
        #2^10=1024だから10までで十分
        numOfDiv = 0
        for k in range(1, 11):
            numOfDiv += n//(p**k)
        numOfPrime.append((p, numOfDiv))
    P = int(1e9)+7
    ans = 1
    for i, j in numOfPrime: 
        ans *= (j+1)
        ans %= P
    print(ans) 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import sqrt, ceil
def solve():
    n = int(input())
    keta = [0] * (n+1)
    for i in range(2, n+1):
        for j in range(2, int(pow(i, 0.5))+1):
            while i % j == 0:
                i //= j
                keta[j] += 1
        keta[i] += 1

    mod = 1000000007
    ans = 1
    keta[0] = 0
    keta[1] = 0
    for ex in keta:
        ans *= (ex + 1)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    keta = [0] * (n+1)
    for i in range(2, n+1):
        for j in range(2, int(pow(i, 0.5))+1):
            if i % j: continue
            ex = 0
            while i % j == 0:
                i = i // j
                ex += 1
            keta[j] += ex
        if i != 1:
            keta[i] += 1

    mod = 1000000007
    ans = 1
    for ex in keta:
        ans = ans * (ex + 1)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())

multiplier = [0 for _ in range(n)]
for m in range(2, n+1):
    a = m
    i = 2
    while i ** 2 <= m:
        while a % i == 0:
            a = int(a / i)
            multiplier[i-1] += 1
        i += 1
    if a != 1:
        multiplier[a-1] += 1
ans = 1
for x in multiplier:
    ans *= x + 1
print(ans % (10**9 + 7))

Submission status: Accepted

Solution code:
n = int(input())
ans = 1
a = [0 for i in range(n+1)]
for k in range(1,n+1):
    i = k
    while i % 2 == 0:
        a[2] += 1
        i //= 2
    j = 3
    while j ** 2 <= i:
        if i % j == 0:
            a[j] += 1
            i //= j
        else:
            j+=2
    if i != 1:
        a[i]+=1
for i in a:
    if i != 0:
        ans *= (i+1)
        ans %= (10**9+7)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3.4.3
n = int(input())
fct = {}  # prime factor
for n in range(1, n + 1):
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct[b] = fct.get(b, 0) + e
        b, e = b + 1, 0
    if n > 1:
        fct[n] = fct.get(n, 0) + 1
p = 1
MOD = 10**9+7
for i in fct.values():
    p *= i + 1 % MOD
    p %= MOD
print(p)

Submission status: Accepted

Solution code:
from collections import Counter
import math
def factorization(n):
    i = 2
    factors = []
    while i <= math.floor(math.sqrt(n)):
        if n%i == 0:
            factors.append(i)
            n //= i
        else:
            i += 1
    if n > 1:
        factors.append(n)
    return factors
N = int(input())
if N==1:
    print(1)
    exit()
c = Counter()
for i in range(1, N+1):
    f = factorization(i)
    c.update(f)
ans = 1
for x in c.values():
    ans *= (x+1)
print(ans % int(1e9+7))

Submission status: Accepted

Solution code:
def cnt_facts(n):
    a = 2
    lst = []
    while a**2 <= n:
        if n % a == 0:
            ex = 0
            while n % a == 0:
                ex += 1
                n //= a
            lst.append([a, ex])
        a += 1
    
    if n != 1: lst.append([n,1])
    
    return lst

n = int(input())
ans_d = {} #素因数分解を格納する辞書
for i in range(2,n+1): #n! の1,2,3...,n-1, nを順に素因数分解し、結果を統合
    l = cnt_facts(i)
    for i in l:
        k = i[0] #素数
        v = i[1] #指数
        if k not in ans_d:
            ans_d[k] = v
        else:
            ans_d[k] += v

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

Submission status: Accepted

Solution code:
def prime_factorize(n):
    result = []
    if n % 2 == 0:
        t = 0
        while n % 2 == 0:
            n //= 2
            t += 1
        result.append((2, t))
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


N = int(input())

t = [0] * (N + 1)
for i in range(2, N + 1):
    for p, e in prime_factorize(i):
        t[p] += e

result = 1
for i in range(2, N + 1):
    if t[i] == 0:
        continue
    result = result * (t[i] + 1) % 1000000007
print(result)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
u=[]
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        u.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            u.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        u.append(n)
    #return a
    return
for i in range(1,n+1):
    prime_factorize(i)
#print(u)
c=Counter(u)
ans=1
for j in c.keys():
    ans=ans*(c[j]+1)%mod
print(ans)

Submission status: Accepted

Solution code:
def fac(n):  #nは2以上
    a=[]
    t=n
    if t%2==0:
        count=0
        while t%2==0:
            count+=1
            t//=2
        a.append([2,count])

    for i in range(3,n+1,2):
        if i*i>n:
            break
        if t%i==0:
            count=0
            while t%i==0:
                count+=1
                t//=i
            a.append([i,count])

    if t!=1:
        a.append([t,1])
    
    return a


from sys import stdin
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    n=int(readline())

    d=dict()
    for i in range(1,n+1):
        tmp=fac(i)
        for j in range(len(tmp)):
            if tmp[j][0] not in d:
                d[tmp[j][0]]=tmp[j][1]
            else:
                d[tmp[j][0]]+=tmp[j][1]

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

    print(ans)

if __name__=="__main__":
    main()

Submission status: Accepted

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

def factorization(n):
    primen, degree, primend = [], [], []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            primen.append(i)
            degree.append(cnt)
            primend.append([i,cnt])
    if temp!=1:
        primen.append(temp)
        degree.append(1)
        primend.append([temp,1])
    if primen==[]:
        primen.append(n)
        degree.append(1)
        primend.append([n,1])
    return primend

N = int(input())
pm = [0]*(1+N)

def main():
    for i in range(1,N+1):
        for x in factorization(i):
            pm[x[0]]+=x[1]
    ret = 1
    for j in pm[2:]:
        ret *= j+1
        ret %= 1000000007
    print(ret)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

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

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush

def solve():
    n = II()

    keta = [0] * (n+1)
    for i in range(2, n+1):
        # iを素因数分解
        for j in range(2, int(pow(i, 0.5))+1):
            if i % j: continue
            ex = 0
            while i % j == 0:
                i = i // j
                ex += 1
            keta[j] += ex
        if i != 1:
            keta[i] += 1
    # print(fact)

    mod = 1000000007
    ans = 1
    for ex in keta:
        ans = ans * (ex + 1)
        ans %= mod
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

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

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush

def solve():
    n = II()

    fact = {}
    for i in range(2, n+1):
        # iを素因数分解
        for j in range(2, int(pow(i, 0.5))+1):
            if i % j: continue
            ex = 0
            while i % j == 0:
                i = i // j
                ex += 1
            fact[j] = fact.get(j, 0) + ex
        if i != 1:
            fact[i] = fact.get(i, 0) + 1
    # print(fact)

    mod = 1000000007
    ans = 1
    for (num, ex) in fact.items():
        ans = ans * (ex + 1)
        ans %= mod
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

#素因数分解
def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
	
N = INT()

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

dic = defaultdict(int)
for i in range(2, N+1):
	for key, value in factorization(i):
		dic[key] += value

#print(dic)
ans = 1
for value in dic.values():
	ans = ans*(value + 1)%mod

print(ans)

Submission status: Accepted

Solution code:
import math
from collections import Counter

n = int(input())
f = math.factorial(n)
mod = 10 ** 9 + 7

factor = []
while f % 2 == 0:
    factor.append(2)
    f //= 2
x = 3
while x ** 2 <= f:
    if f % x == 0:
        factor.append(x)
        f //= x
    else:
        x += 2

if f != 1:
    factor.append(f)

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

Submission status: Accepted

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

# 素因数分解 - 試し割り法
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

d = {}

for i in range(1,n+1):
    arr = factorization(i)
    for num, cnt in arr:
        if num in d:
            d[num] += cnt
        else:
            d[num] = cnt

ans = 1

for num in d:
    if num != 1:
        ans *= (d[num] + 1) % mod
        ans %= mod

print(ans)

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()

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

dic = DD(int)

for i in range(2,N+1):
  for k,v in factorization(i):
    dic[k] += v

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

Submission status: Accepted

Solution code:
from math import sqrt

def factors(n):
    N = n
    prime_dict = {}
    for i in range(2,int(sqrt(n))+1):
        if n % i == 0:
            prime_dict[i] = 1
            n //= i
            while n % i == 0:
                prime_dict[i] += 1
                n //= i
        if n == 1:
            break
    if n != 1:
        prime_dict[n] = 1
    return prime_dict

def factorial(n):
    if n == 1:
        return 1
    else:
        prime_set,prime_dict = set(),{}
        for i in range(2,n+1):
            F = factors(i)
            for fa in F:
                if fa not in prime_set:
                    prime_set.add(fa)
                    prime_dict[fa] = F[fa]
                else:
                    prime_dict[fa] += F[fa]

        output,M = 1,10**9+7
        for pr in prime_dict:
            output *= (prime_dict[pr]+1)
            output %= M
        return output

def main():
    N = int(input())

    print(factorial(N))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

p = []
for i in range(1,n+1):
	if is_prime(i):
		p.append(i)
ans = 1
for i in p:
	s = 0
	x = i
	while x <= n:
		s += n//x
		x *= i
	ans *= (s+1)
	ans %= mod
print (ans)

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)
 
# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
 
 
# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
 
 
# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
 
# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)
 
# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)
 
# 素数判定
 
 
 
# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
 
    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P
 
# 同じものを含む順列
def permutation_with_duplicates(L):
 
    if L == []:
        return [[]]
 
    else:
        ret = []
 
        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))
 
        for i in S:
 
            data = L[:]
            data.remove(i)
 
            for j in permutation_with_duplicates(data):
                ret.append([i] + j)
 
        return ret
 
 
n = int(input())
s=[]
res=1
for i in range(2,n+1):

    if is_prime(i):
        a=n
        cnt=0
        t=1
        r=a
        while r>0:
            r=a//(i**t)
            cnt+=r
            t=t+1
        
        res=res*(cnt+1)
print(res%MOD)

Submission status: Accepted

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

for i in range(2, N+1):
    for j in range(2, i+1):
        while i % j == 0:
            i  = i // j
            try:
                memo[j] += 1
            except:
                memo[j] = 1

ans = 1
for key in memo.keys():
    ans *= memo[key] + 1

print(ans%mod)

Submission status: Accepted

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

for i in range(2, N+1):
    for j in range(2, i+1):
        while i % j == 0:
            i  = i // j
            try:
                memo[j] += 1
            except:
                memo[j] = 1

ans = 1
for key in memo.keys():
    ans *= memo[key] + 1
    ans %= mod

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
mod=10**9+7
ans=[0]*(1000+1)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for i in range(1000+1):
  for j in factorization(i):
    ans[j[0]]+=j[1]
  if n==i:
    break
anss=1
for i in range(2,len(ans)):
  anss*=(ans[i]+1)%mod
  anss%=mod
print(anss)

Submission status: Accepted

Solution code:
n=int(input())
mod=10**9+7
ans=[0]*(1000+1)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for i in range(1000+1):
  for j in factorization(i):
    ans[j[0]]+=j[1]
  if n==i:
    break
anss=1
for i in range(2,len(ans)):
  anss*=(ans[i]+1)%mod
  anss%=mod
print(anss)

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


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

# 素数列挙
primes = []
is_prime = [True]*(N+1)
for i in range(2,N+1):
    if is_prime[i]:
        primes.append(i)
        j = 2
        while i*j < N+1:
            is_prime[i*j] = False
            j += 1

# 約数の集計用
from collections import defaultdict
div = defaultdict(int)

ans = 1
# N = 2 から全探索
for i in range(2,N+1):
    for p in primes:
        if p > i:
            break
        cnt = 0
        while i%p==0:
            i //= p
            cnt += 1
        div[p] += cnt

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

print(ans)