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())
factors = {}

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

    while p > 1:
        f = False
        for j in range(2, int(p**0.5)+1):
            if p % j == 0:
                if j in factors:
                    factors[j] += 1
                else:
                    factors[j] = 1

                p //= j
                f = True
                break

        if not f:
            if p in factors:
                factors[p] += 1
            else:
                factors[p] = 1
            break

ans = 1
for f in factors.values():
    ans *= f+1

print(ans % 1000000007)

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

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

class Osa_k():
    def __init__(self, n):
        self.sieve = list(range(n + 1))
        self.sieve[0] = 1 #素数でない
        self.sieve[1] = 1 #素数でない
        m = int(math.sqrt(n))
        for i in range(2, m + 1):
            if self.sieve[i] < i:
                continue
            for j in range(i * i, n + 1, i):
                if self.sieve[j] == j:
                    self.sieve[j] = i

    def factorize(self, n):
        prime = defaultdict(int)
        if n == 0 or n == 1:
            return (n, 1)
        opt = n
        while opt > 1:
            prime[self.sieve[opt]] += 1
            opt //= self.sieve[opt]
        return sorted(prime.items())

N = getN()
O = Osa_k(10 ** 6 + 1)

prime = defaultdict(int)
for i in range(2, N + 1):
    for j in O.factorize(i):
        prime[j[0]] += j[1]

ans = 1
for i in prime.items():
    ans *= i[1] + 1
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
from collections import defaultdict
p=defaultdict(int)
def f(n):
    for i in range(2,int(n**.5)+1):
        x=0
        while n%i==0:
            n//=i
            x+=1
        if x:
            p[i]+=x
    if n>1:
        p[n]+=1
for i in range(2,N+1):
    f(i)
from functools import reduce
print(reduce(lambda x,y:x*(y+1),p.values(),1)%(10**9+7))

Submission status: Accepted

Solution code:
# 6!は6*5*4*3*2*1
# それぞれを素因数分解すると、3*2*5*2*2*3*2*1となる
# それぞれの個数は5が1個、2が4個、3が2個である
# 選ばない場合もあるので、+1した値をかける
# 2*5*3=30個になる


def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


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

mp = [0]*1000
for i in range(2, N+1):
    pf = prime_factorization(i)
    for p in pf:
        mp[p] += 1

ans = 1
for p in mp:
    if p == 0:
        continue

    ans = ans*(p+1)

print(ans % MOD)

Submission status: Accepted

Solution code:
def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


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

mp = [0]*1000
for i in range(2, N+1):
    pf = prime_factorization(i)
    for p in pf:
        mp[p] += 1

ans = 1
for p in mp:
    if p == 0:
        continue

    ans = ans*(p+1)

print(ans % MOD)

Submission status: Accepted

Solution code:
N = int(input())

mod = 10**9+7
so = [0]*N

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(2, N+1):
    arr = factorization(i)
    for a in arr:
        so[a[0]-1] += a[1]

ans = 1
for s in so:
    ans *= s+1
    ans %= mod

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

class factorials:
    '''
    args:
      n : max val when exploring factorials
    '''
    def __init__(self, n=1):
        self.n = 1# factorials to be searched
        self.factorials = []
        self.update_factorials(n)

    def update_factorials(self, n):
        if self.n >= n:
            return None
        for i in range(self.n+1, n+1):
            done = False
            limit = int(i ** 0.5)
            for j in self.factorials:
                if j > limit: break
                if not i % j:
                    done = True
                    break
            if not done:
                self.factorials.append(i)
        self.n = n
        return None

    def factorials_list(self):
        return self.factorials

    def check_fact(self, x):
        if x > self.n**2:
            self.update_factorials(int(x ** 0.5)+1)
        for f in self.factorials:
            if not x % f:
                return False
        return True

    def prime_factorization(self, val, divisors=None):
        # divisors : default-dict of divisors. Should be specified only if appended vals are required
        max_n = int(math.sqrt(val))
        if self.n < max_n:
            self.update_factorials(max_n)
        if divisors == None:
            divisors = defaultdict(lambda: 0)
        for f in self.factorials:
            if f > val: break
            while True:
                if not val % f:
                    divisors[f] += 1
                    val //= f
                else:
                    break
        if val > 1:
            divisors[val] += 1
        return divisors

def run():
    N = int(input())
    FACT = factorials()
    max_n = int(math.sqrt(N))
    divisors = defaultdict(lambda: 0)
    for n in range(2, N+1):
        divisors = FACT.prime_factorization(n, divisors)
    #print(divisors)
    mod = 10 ** 9 + 7
    ans = 1
    for key, value in divisors.items():
        ans *= value+1
        ans %= mod
    print(ans)

if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def factorials(n):
    facts = []
    for k in range(2, n+1):
        done = False
        max_f = int(math.sqrt(k))
        for f in facts:
            if f > max_f:break
            if not k % f:
                done = True
                break
        if not done:
            facts.append(k)
    return facts

def prime_factorization(val, facts = None, divisors = None):
    if facts == None:
        max_n = int(math.sqrt(val))
        facts = factorials(max_n)
    if divisors == None:
        divisors = defaultdict(lambda:0)
    for f in facts:
        if f > val:break
        while True:
            if not val % f:
                divisors[f] += 1
                val //= f
            else:
                break
    if val > 1:
        divisors[val] += 1

    return divisors

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

    max_n = int(math.sqrt(N))
    facts = factorials(max_n)
    divisors = defaultdict(lambda: 0)
    for n in range(2, N+1):
        divisors = prime_factorization(n, facts, divisors)
    #print(divisors)
    mod = 10 ** 9 + 7
    ans = 1
    for key, value in divisors.items():
        ans *= value+1
        ans %= mod
    print(ans)

if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
N = int(input())
prime_cnt = [0] * 1000
ans = 0
for i in range(2, N + 1):
    work = i
    for j in range(2, int(i ** (1 / 2)) + 1):
        while work % j == 0:
            prime_cnt[j - 1] += 1
            work //= j
    if work != 1:
        prime_cnt[work - 1] += 1
# print(prime_cnt)
ans = 1
mod = 10 ** 9 + 7
for cnt in prime_cnt:
    if cnt:
        ans *= (cnt + 1)
        ans %= mod
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
divisor=[0]*(N+1)
count=[0]*(N+1)
for i in range(2,N+1):
    if divisor[i]:
        continue
    j=1
    while i*j<=N:
        divisor[i*j]=1
        now=i*j
        while now%i==0:
            count[i]+=1
            now//=i
        j+=1
ans=1
M=10**9+7
for i in range(N+1):
        ans*=(count[i]+1)
        ans%=M
print(ans)

Submission status: Accepted

Solution code:
import math
from collections import defaultdict
N = int(input())
mod = 10 ** 9 + 7
d = defaultdict(int)

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

for n in range(1, N + 1):
    for i in range(2, math.ceil(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            d[i] += 1

    if (n != 1):
        d[n] += 1

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    if N == 1:
        print(1)
        sys.exit()
    div = defaultdict(int)
    for n in range(1, N + 1):
        for i in range(2, int(n ** 0.5) + 1):
            while n % i == 0:
                n //= i
                div[i] += 1
        if n != 1:
            div[n] += 1

    ans = 1
    for Value in div.values():
        ans *= (Value+1) % MOD
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
c = Counter()


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

for i in range(1, n + 1):
    c.update(prime_factorize(i))
    
ans = 1
mod = 10**9+7
for v in c.values():
    ans *= v + 1
    ans %= mod 

print(ans)

Submission status: Accepted

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

# In[38]:


N = int(input())


# In[39]:


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


# In[41]:


mydict = {}
for i in range(1,N+1):
    mylist = factorization(i)
    for x in mylist:
        if x[0] in mydict.keys():
            mydict[x[0]] += x[1]
        else:
            mydict[x[0]] = x[1]
ans = 1
for j,y in mydict.items():
    if j > 1:
        ans *= y+1
print(ans%(10**9+7))


# In[ ]:

Submission status: Accepted

Solution code:
n = int(input())
val = [1 for _ in range(n)]
ans = 1
for i in range(2, n+1):
    for j in range(2, i+1):
        while i%j == 0:
            val[j-1] += 1
            i //= j
    if i != 1:
        val[i-1] += 1

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

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

def factorization(n):
    p=2
    fcr=[]
    while p*p<=n:
        while n%p==0:
            fcr.append(p)
            n//=p
        p+=1
    if n>1:
        fcr.append(n)
    return fcr

n=int(input())

mod=10**9+7

l=[]
for i in range(1,n+1):
  l+=factorization(i)

c=Counter(l)
ans=1
for i in c:
  ans*=(c[i]+1)
  ans%=mod

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
def count(x):
    c = 0
    t = n
    while t:
        c += t//x
        t //= x
    return c +1
limit = int(n**0.5)
ans = count(2)
if n < 3:
    print(ans)
    exit()
data = [i + 1 for i in range(2, n, 2)]
while data:
    p = data[0]
    ans *= count(p)
    ans %= 10**9 + 7
    data = [e for e in data if e % p != 0]
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
def count(x):
    c = 0
    t = n
    while t:
        c += t//x
        t //= x
    return c +1
prime = [2]
limit = int(n**0.5)
ans = count(2)
if n < 3:
    print(ans)
    exit()
data = [i + 1 for i in range(2, n, 2)]
while True:
    p = data[0]
    if limit < p:
        for i in data:
            ans *= count(i)
            ans %= 10**9+7
        break
    ans *= count(p)
    ans %= 10**9 + 7
    data = [e for e in data if e % p != 0]
print(ans)

Submission status: Accepted

Solution code:
def p_factorization(n):
    if n == 1: return {}
    pf_cnt = {}
    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
            pf_cnt[i] = cnt

    if temp != 1: pf_cnt[temp] = 1
    return pf_cnt


n = int(input())
pf_cnts = {}
for i in range(2,n+1):
    i_pf_cnt = p_factorization(i)
    for k,v in i_pf_cnt.items():
        pf_cnts.setdefault(k,0)
        pf_cnts[k] += v

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

print(ans)

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7
n = int(input())
d = {}
for i in range(1, n + 1):
    j = 2
    while j * j <= i:
        while i % j == 0:
            if j in d:
                d[j] += 1
            else:
                d.setdefault(j, 1)
            i //= j
        j += 1
    if i != 1:
        if i in d:
            d[i] += 1
        else:
            d.setdefault(i, 1)
m = 1
for v in d.values():
    m *= v + 1
print(m % MOD)

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())
mod = 10**9 + 7

values = [i for i in range(N+1)]
factors = {}
exists = set()
for i in range(2, N+1):
    if i not in factors:
        factors[i] = 0
    for j in range(i, N+1, i):
        tmp = values[j]
        while tmp % i == 0:
            factors[i] += 1
            tmp //= i
        values[j] = tmp

# print(values)
# print(factors)
ans = 1
for factor, count in factors.items():
    ans *= count + 1
    ans %= mod

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

Submission status: Accepted

Solution code:
p = 10**9+7
P = [1 for _ in range(1000)]
P[0]=0
P[1]=0
for i in range(2,35):
    for j in range(i**2,1000,i):
        P[j]=0
Q = []
for i in range(2,1000):
    if P[i]==1:
        Q.append(i)
N = int(input())
C = {q:0 for q in Q}
for i in range(2,N+1):
    x = i
    for q in Q:
        if x%q==0:
            while x%q==0:
                x = x//q
                C[q] += 1
cnt = 1
for q in Q:
    cnt = (cnt*(C[q]+1))%p
print(cnt)

Submission status: Accepted

Solution code:
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]]

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

P = primes(N)

ans = 1

for p in P:
    cnt = 1
    tmp = p
    while tmp <= N:
        cnt += N // tmp
        tmp *= p
    ans *= cnt
    ans %= mod

print(ans)

Submission status: Accepted

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

div = [1 for _ in range(n + 1)]
for num in range(2, n + 1):
    for i in range(2, int(num ** 0.5) + 1):
        while num % i == 0:
            div[i] += 1
            num //= i
    if num != 1:
        div[num] += 1

ans = 1

for num in div:
    ans *= num
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#================================================
N=int(input())

if N==1:
    print(1)
else:
    D={}
    for k in range(2,N+1):
        T=Prime_Factorization(k)
        for p,e in T:
            if p in D:
                D[p]+=e
            else:
                D[p]=e

    M=10**9+7
    X=1
    for p in D:
        X*=D[p]+1
        X%=M
    print(X)

Submission status: Accepted

Solution code:
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy

def bun(n):
    ret = defaultdict(int)
    for i in range(2, int(n//2 + 2)):
        while(n%i == 0):
            ret[i] += 1
            n //= i

    if len(ret.keys()) == 0:
        return {n: 1}
    else:
        return ret

def solve():
    n = getN()
    d = defaultdict(int)
    for i in range(2, n+1):
        for k, v in bun(i).items():
            d[k] += v

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


def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Submission status: Accepted

Solution code:
from collections import defaultdict


def factorize(N):  # 素因数分解
    p = 2
    while p * p <= N:
        if N % p == 0:
            N //= p
            d[p] += 1
        else:
            p += 1
    if N > 1:
        d[N] += 1
    return



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

d = defaultdict(int)
for i in range(1, n + 1):
    factorize(i)

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

Submission status: Accepted

Solution code:
import math
N = int(input())
d = {}

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

  if temp!=1:
    if temp in d:
      d[temp] += 1
    else:
      d[temp] = 1
    arr.append(temp)

  if arr==[]:
    if n in d:
      d[n] += 1
    else:
      d[n] = 1
    
for i in range(2, N+1):
  main(i)
ans = 1
for i in d.values():
  ans *= (i+1)
ans = ans % (10**9+7)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# 整数の入力
n = int(input())

#素因数分解
def PrimeFactorization(n):
    ret = []
    for i in range(2, int(n ** 0.5)+1):
        if n % i != 0:
            continue
        
        exp = 0
        while n % i == 0:
            exp += 1
            n //= i
        
        ret.append([i, exp])

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

    return ret

a = [0]*(n+1)
for i in range(2, n+1):
    tmp = PrimeFactorization(i)
    for j in range(len(tmp)):
        a[tmp[j][0]] += tmp[j][1]


ret = 1
#print(a)
for i in a:
    ret *= (i+1)
    ret %= 1000000007

print(ret)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
mod = 10**9+7
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        primes[2]+=1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            primes[f]+=1
            n //= f
        else:
            f += 2
    if n != 1:
        primes[n]+=1
    return

primes = [0]*(N+1)
for i in range(1, N+1):
    prime_factorize(i)
ans = 1
for p in primes:
    ans *= (p+1)
    ans %= mod
print(ans)

Submission status: Accepted

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

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

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

d = {}

for i in range(2, N+1):
    D = factorization(i)
    for n in D:
        if n[0] in d: d[n[0]] += n[1]
        else: d[n[0]] = n[1]

ret = 1

for k, v in d.items():
    ret *= v + 1

print(ret%MOD)

Submission status: Accepted

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

from fractions import gcd
# from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
import math

N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = Counter(prime_factorize(math.factorial(N)))

ret = 1
for key, item in c.items():
    ret = ret * (item+1)
print(ret % (10**9 +7))

Submission status: Accepted

Solution code:
n=int(input())
d={i:0 for i in range(n+1)}
for i in range(2,n+1):
    for j in range(2,int(i**0.5)+1):
        while i%j==0:
            i//=j
            d[j]+=1
    if i!=1:
        d[i]+=1
a=1
mod=10**9+7
for i in d.values():
    a=a*(i+1)%mod
print(a)

Submission status: Accepted

Solution code:
n=int(input())
MOD=10**9+7
cnt=[0 for _ in range(1000)]
for i in range(2,n+1):
    e=i
    for j in range(2,i+1):
        while(e%j==0):
            e//=j
            cnt[j]+=1
ans=1
for i in range(1000):
    ans=(ans*(cnt[i]+1))%MOD
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def get_prime(N):
    prime = dict()
    prime[1] = 1
    i = 2
    while i * i <= N:
        while N % i == 0:
            if i in prime.keys():
                prime[i] += 1
            else:
                prime[i] = 1
            N = N // i
        i += 1
    if N != 1:
        prime[N] = 1
    return prime


def main():
    N = int(input().strip())
    div_table = [0] * (N + 1)
    MOD = 10**9 + 7
    ans = 1
    for i in range(2, N + 1):
        for j in range(i, N + 1, i):
            div_table[j] += 1

    prime = dict()
    for i in range(2, N + 1):
        if div_table[i] == 1:
            prime[i] = 0

    for i in range(2, N + 1):
        _prime = get_prime(i)
        for k, v in _prime.items():
            if k == 1:
                continue
            prime[k] += v

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
P = 10**9+7
  
memo = [0]*(N+1)

for i in range(1,N+1):
  j = i
  while j % 2 == 0:
    memo[2] += 1
    j //= 2
  k = 3
  while k*k <= j:
    if j % k == 0:
      memo[k] += 1
      j //= k
    else:
      k += 2
  if j != 1:
    memo[j] += 1
    
rlt = 1  
for i in range(1,N+1):
  rlt *= (memo[i]+1)%P
  rlt %= P
  
print(rlt)

Submission status: Accepted

Solution code:
import math
N = int(input())
S = math.factorial(N)
T = [i for i in range(2, N+1)]
s = 1
while len(T)>0:
  c = 1
  while S%T[0]==0:
    S //= T[0]
    c += 1
  s *= c
  s %= 10**9+7
  T = [t for t in T if t%T[0]]
print(s)

Submission status: Accepted

Solution code:
ans=1
c=[0]*10001
for i in range(1,int(input())+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  
for i in c:
    ans*=i+1
    ans%=10**9+7
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    from collections import defaultdict
    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[i] += cnt

        if temp!=1:
            arr[temp]+= 1

        if n ==1:
            arr[temp] += 1

        return arr

    n = int(input())
    mod = 10**9 + 7
    arr = [0]*(n+1)
    for i in range(2, n+1):
        arr = factorization(i, arr)
    
    ans = 1
    for a in arr:
        ans *= (a+1)
        ans %= mod
    
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from functools import lru_cache
from collections import Counter

N = int(input())

@lru_cache()
def factor(n):
    fact = []
    i = 2
    while n >= i * i:
        while n%i == 0:
            fact.append(i)
            n //= i
        i += 1
    if n > 1:
        fact.append(n)
    
    return fact

fact = []
for i in range(2,N+1):
    fact.extend(factor(i))


cf = Counter(fact)

ans = 1
for f,n in cf.items():
    ans = ans *(n+1) % (10**9+7)

print(ans)

Submission status: Accepted

Solution code:
import math
from collections import Counter
n=math.factorial(int(input()))
dp=[]
for i in range(2,1001):
  while n%i==0:
    n//=i
    dp.append(i)
c=list(Counter(dp).items())
ans=1
for j in range(len(c)):
  ans*=c[j][1]+1
print(ans%1000000007)