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())

P = [2]
for i in range(3, 1001, 2):
    flag = True
    for p in P:
        if i % p == 0:
            flag = False
            break
    if flag:
        P.append(i)

ans = 1
for p in P:
    if p > N:
        break
    t = 0
    i = 1
    while (p ** i) <= N:
        t += N // (p ** i)
        i += 1
    ans *= 1 + t

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

Submission status: Accepted

Solution code:
mod=1000000007
n=int(input())
d={}
for i in range(2,1001):
    cnt=1
    for j in range(2,i//2+1):
        if i%j==0:
            cnt=0
    if cnt==1:
        d[i]=0
p=list(d.keys())
for k in range(2,n+1):
    for i in p:
        cnt=0
        while k%i==0:
            k=k//i
            cnt+=1
        if cnt!=0:
            d[i]+=cnt
a=list(d.values())
ans=1
for i in a:
    if i!=0:
        ans*=(i+1)
        ans%=mod
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    return

#B
def B():
    n = I()

    return

#C
def C():
    def factor(n):
        if n < 4:
            return {1:1,n:1}
        else:
            d = defaultdict(lambda : 0)
            i = 2
            m = n
            while i**2 <= n:
                if m%i == 0:
                    while m%i == 0:
                        d[i] += 1
                        m //= i
                i += 1
            d[m] += 1
            return d
    n = I()
    if n == 1:
        print(1)
        quit()
    f = defaultdict(lambda : 0)
    for i in range(2,n+1):
        fact = factor(i)
        for j,k in fact.items():
            if j > 1:
                f[j] += k
                f[j] %= mod
    ans = 1
    for i in f.values():
        ans *= (i+1)
        ans %= mod
    print(ans)
    return

#D
def D():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

    n,a,b = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    x = LI()
    for i in range(n-1):
        if a*(x[i+1]-x[i]) < b:
            unite(i,i+1)
    ans = 0
    f = [1]*n
    f[0] = 0
    for i in range(1,n):
        if f[root(i)]:
            ans += b
            f[root(i)] = 0
        else:
            ans += a*(x[i]-x[i-1])
    print(ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Accepted

Solution code:
n=int(input())
def soinsuu(a):
    yakusuu=[]
    j=2
    while(a>1):
        for i in range(j,int(a**0.5)+1):
            if a%i==0:
                yakusuu.append(i)
                a=a//i
                j=i
                break
        else:
            yakusuu.append(a)
            break
    yakusuu.sort()
    return yakusuu
ans=[]
from collections import Counter
for i in range(2,n+1):
    ans+=soinsuu(i)
ans2=1
mod=10**9+7
for i in Counter(ans).values():
    ans2=(ans2*(i+1))%mod
print(ans2)

Submission status: Accepted

Solution code:
MOD = 10**9+7
n = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(2, n+1):
  j = 2
  while j*j<=i:
    while i%j==0:
      i //= j
      d[j] += 1
    j += 1
  if i>1:
    d[i] += 1
ans = 1
for ele in d.values():
  ans = ans*(ele+1)%MOD
print(ans)

Submission status: Accepted

Solution code:
import functools

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

primes = [2]

for i in range(3, N + 1):
    if not [p for p in primes if i % p == 0]:
        primes.append(i)

count = {p: 0 for p in primes}
for i in range(1, N + 1):
    num = i
    for p in primes:
        while num % p == 0:
            count[p] += 1
            num //= p

print(functools.reduce(lambda s, c: s * (c + 1) % MOD, count.values(), 1))

Submission status: Accepted

Solution code:
import math
n=math.factorial(int(input()))
a,i=1,2
while i*i<=n:
  c=1
  while n%i==0:
    c+=1
    n//=i
  a*=c
  i+=1
print(a*2**(n!=1)%(10**9+7))

Submission status: Accepted

Solution code:
n = list(map(int, input().split()))
n = n[0]

primes = []

for i in range(n+1):
    if(i<2):
        continue
    flag = 1
    for j in range(len(primes)):
        flag *= i%primes[j]
    if(flag != 0):
        primes.append(i)

nump = len(primes)
times = [0 for i in range(nump)]

for i in range(nump):
    for j in range(10):
        times[i] += n//primes[i]**(j+1)


ans = 1
for i in range(nump):
    ans = (ans*(times[i]+1))%1000000007

print(ans)

Submission status: Accepted

Solution code:
# ARC067C - Factors of Factorial
def count_divisors(num: int) -> int:
    max_prime = 0
    dic = {}
    res = 1

    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        dic[max_prime] = cnt

    cnt = 0
    for i in range(3, int(num ** 0.5) + 1, 2):
        cnt = 0
        while num % i == 0:
            num //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            dic[max_prime] = cnt

    if num > 2:
        max_prime = num
        dic[max_prime] = 1

    return dic


def main():
    n = int(input())
    MOD = 10 ** 9 + 7
    f = {}
    for i in range(2, n + 1):
        for j, k in count_divisors(i).items():
            if j not in f:
                f[j] = 0
            f[j] += k
    ans = 1
    for i in f.values():
        ans = (ans * (i + 1)) % MOD
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

div = [0]*1000
ans = 1
for j in range(1,N+1):
    n = j
    for i in range(2,n+1):
        while n % i == 0:
            div[i] += 1
            n //= i

for num in div:
    ans *= (num+1)

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

Submission status: Accepted

Solution code:
import math
from collections import defaultdict

#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        factor.append(n)
        factor.append(1)
        return factor
    else:
        factor.append(n)
        return factor

N = int(input())
l = defaultdict(int)
for i in range(1,N+1):
    for j in trial_division(i):
        if j != 1:
            l[j] += 1

ans = 1
for i in list(l.values()):
    ans *= (i+1)

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

Submission status: Accepted

Solution code:
N = int(input())

from math import factorial
num_divide = factorial(N)

divided = False

factor_dict = {}

for i in range(2, N + 1):
    for t in range(2, i + 1):
        
        while i % t == 0:
        
            i /= t
            if t not in factor_dict:
                factor_dict[t] = 1
            else:
                factor_dict[t] += 1

        if i == 1:
            break

count = 1
for key, value in factor_dict.items():
    count *= value + 1
    count %= (1000000007)
print(count)

Submission status: Accepted

Solution code:

N = int(input())
mod = 10**9+7
# 素因数分解(小さい方から順に割っていく)
divisors = [0]*(N+1)
for j in range(2,N+1):
    s = 0
    L = j
    while s == 0:
        for i in range(2,N+1):
            if L % i == 0:
                divisors[i] += 1
                L //= i
                if L == 1:
                    s = 1 #1はこれ以上素因数を産まない
                break
cnt = 1
for div in divisors:
    if div > 0:
        cnt*=(div+1)
print(cnt%mod)

Submission status: Accepted

Solution code:
import math
n = math.factorial(int(input()))
i = 2
ans = 1
M = 10**9+7
while i*i <= n:
  cnt = 1
  while n%i == 0:
    cnt += 1
    n //= i
  ans *= cnt
  i += 1
if n != 1:
  ans *= 2
print(int(ans%M))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
C - Factors of Factorial
https://atcoder.jp/contests/arc067/tasks/arc067_a

"""
import sys



from collections import Counter

def prime_factor(N):
    factors = Counter()
    for i in range(2, int(N**0.5)+1):
        while N % i == 0:
            factors[i] += 1
            N //= i
    if N != 1:
        factors[N] = 1
    return factors


def solve(N):
    f = Counter()
    for i in range(1, N+1):
        f += prime_factor(i)

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


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
N = int(input())

is_prime=[1]*(N+1) #is_prime[p]: pが素数か
n_factors = {}

for p in range(2,N+1):
  if is_prime[p] == 0:
    continue
  else:
    q = 2*p
    while q <=N:
      is_prime[q] = 0
      q+=p
    for n in range(p,N+1):
      while n%p ==0:
        n_factors[p] = n_factors.get(p,0) + 1
        n=n//p
#print(n_factors)
ans = 1
for f in n_factors.values():
  ans *= (f+1)
  ans %= 10**9+7
  
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
from itertools import chain


def fast_prime_set(n):
    # nまでの素数リスト高速版 setで返す
    # chainの読み込みが必要！
    if n < 4:
        return ({}, {}, {2}, {2, 3})[n]
    n_sqrt = int(n ** 0.5) + 1
    primes = {2, 3} | set(chain(range(5, n + 1, 6), range(7, n + 1, 6)))
    for i in range(5, n_sqrt, 2):
        if i in primes:
            primes.difference_update(range(i * i, n, i * 2))
    return primes


def prime_factorization(x):
    # 素因数分解
    # 事前に素数のセットが必要
    primes = fast_prime_set(1000)

    fact = defaultdict(int)
    for prime in primes:
        while x % prime == 0:
            fact[prime] += 1
            x //= prime
        if x == 1:
            break
        if x in primes:
            fact[x] += 1
            break
    return fact


n = int(input())
div_c = defaultdict(int)

for i in range(1, n+1):
    for item, cnt in prime_factorization(i).items():
        div_c[item] += cnt

div_c[1] = 0
ans = 1
mod = 10 ** 9 + 7

for c in div_c.values():
    ans *= (c + 1)
    ans %= mod

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
p=[2]
d=[0 for i in range(n+1)]
for i in range (2,n+1):
    j=0
    t=i
    while len(p)>j:
        a=p[j]
        if(t%a==0):
            d[a]+=1
            t//=a
        else:
            j+=1
    else:
        if(t==i):
            d[t]+=1
            p.append(i)
ans=1
for i in d[2:]:
    ans*=i+1
print(ans%1000000007)

Submission status: Accepted

Solution code:
n=int(input())
l=[k for k in range(1,n+1)]
phrase=[]
ans=1
a=1
def prime(x):
    i=2
    while i*i<=x:
        if x%i==0:
            return False
        i+=1
    return True
for i in range(2,n+1):
    if prime(i):
        phrase.append(i)
for j in phrase:
    for m in range(n):
        while l[m]%j==0:
            a+=1
            l[m]=l[m]/j
    ans=ans*a
    a=1
print(ans%1000000007)

Submission status: Accepted

Solution code:
from collections import Counter

mod = 10**9 + 7

N = int(input())

c = Counter()

import math
def factoring(n):
    sup = math.floor(pow(n,1/2))
    for i in range(2,sup + 1):
        while n % i == 0:
            n //= i
            c[i] += 1
    if n != 1:
        c[n] += 1

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

c = c.values()

ans = 1
for i in c:
    ans *= i+1
    ans %= mod

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
prime = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37)
factor = {}
for i in prime:
    factor[i] = 0

for i in range(n):
    test = i+1
    for j in prime:
        while test%j == 0:
            factor[j] += 1
            test //= j
    if test != 1:
        if test not in factor:
            factor[test] = 1
        else:
            factor[test] += 1

ans, MOD = 1, 10**9+7
for i in factor:
    ans *= factor[i]+1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
import math
import collections

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

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

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

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

p = primes(10000)
dic = collections.defaultdict(int)
N = int(input())
mod = 10**9 +7
for i in range(1, N+1):
    for j in p:
        while i % j == 0:
            dic[j] += 1
            i = i // j
    ans = 1
for c in dic.values():
    ans *= (c+1)
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import math
import collections

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

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

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

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

p = primes(1000)
dic = collections.defaultdict(int)
N = int(input())
mod = 10**9 +7
for i in range(1, N+1):
    for j in p:
        while i % j == 0:
            dic[j] += 1
            i = i // j
    ans = 1
for c in dic.values():
    ans *= (c+1)
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import math
import collections
def primes(n):
    a = list(range(2, n+1))
    primes = [2]
    for i in a:
        flag = True
        m = math.sqrt(i)
        for j in primes:
            if j > m:
                break
            else:
                if i % j == 0:
                    flag = False
                    break
        if flag:
            primes.append(i)
            
    return primes
p = primes(10000)
dic = collections.defaultdict(int)
N = int(input())
mod = 10**9 +7
for i in range(1, N+1):
    for j in p:
        while i % j == 0:
            dic[j] += 1
            i = i // j
    ans = 1
for c in dic.values():
    ans *= (c+1)
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import math
import collections
def primes(n):
    a = list(range(2, n+1))
    primes = [2]
    for i in a:
        flag = True
        m = math.sqrt(i)
        for j in primes:
            if j > m:
                break
            else:
                if i % j == 0:
                    flag = False
                    break
        if flag:
            primes.append(i)
            
    return primes
p = primes(1000)
dic = collections.defaultdict(int)
N = int(input())
mod = 10**9 +7
for i in range(1, N+1):
    for j in p:
        while i % j == 0:
            dic[j] += 1
            i = i // j
    ans = 1
for c in dic.values():
    ans *= (c+1)
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
mo=10**9+7
n=int(input())
from collections import defaultdict
d=defaultdict(int)

for i in range(2,n+1):
    t=int(i**0.5+2)
    for j in range(2,t):
        while i%j==0:
            i//=j
            d[j]+=1
        if i==1:
            break
    if i>1:
        d[i]+=1
ans=1
for i in d.items():
    ans*=i[1]+1
    ans%=mo
print(ans)

Submission status: Accepted

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

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

    for prime in primes:
        if prime > x**0.5:
            break

        if prime == 0:
            continue

        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

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


N = int(input())
prime_arr = primes(N + 1)
arr = [1 for i in range(N + 1)]
for i in range(2, N + 1):
    n = i

    for prime in prime_arr:
        while n % prime == 0:
            n //= prime
            arr[prime] += 1
        if n == 1:
            break

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

print(ans % (1000000007))

Submission status: Accepted

Solution code:
from collections import Counter

def factoring(N, factor_prev):
    '''
    input:
    N, factor_prev: 素因数分解すべきN, Nまでに存在する素数のリスト
    output
    N_dict, factor_list: Nの素因数分解の辞書: 例えば12の場合{2: 2, 3: 1}, Nが素数の場合はfactor_prevにNを追加して返す。Nが素数でない場合は引数を返す。
    '''
    
    factor_list = factor_prev
    N_dict = {}
    
    while True:
        if N == 1:
            return N_dict, factor_list
        
        for factor in factor_prev:
            if N % factor == 0:
                N = N // factor
                
                # 集計部分
                if factor in N_dict:
                    N_dict[factor] += 1
                    break
                    
                else:
                    N_dict[factor] = 1
                    break
                    
            #素数の場合
            if factor == factor_prev[-1] and N % factor != 0:
                factor_list.append(N)
                N_dict[N] = 1
                return N_dict, factor_list
              
def factorial_factoring(N):
    # 例外処理
    if N == 1:
        return {2: 0}
    
    else:
        factorial_factoring_dict = {}
        
        for i in range(2, N+1):
            if i == 2:
                N_dict = {2: 1}
                factor_prev = [2]
                factorial_factoring_dict = Counter(factorial_factoring_dict) + Counter(N_dict)
            else:
                N_dict, factor_prev = factoring(i, factor_prev)
                factorial_factoring_dict = Counter(factorial_factoring_dict) + Counter(N_dict)
    
    return(factorial_factoring_dict)
  
divisor = 1
mod = 1000000007
N = int(input())
for _, v in factorial_factoring(N).items():
    divisor = divisor * (v + 1)
print(divisor % mod)

Submission status: Accepted

Solution code:
n = int(input())
prime = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37)
factor = {}
for i in prime:
    factor[i] = 0

for i in range(n):
    test = i+1
    for j in prime:
        while test%j == 0:
            factor[j] += 1
            test //= j
    if test != 1:
        if test not in factor:
            factor[test] = 1
        else:
            factor[test] += 1

ans, MOD = 1, 10**9+7
for i in factor:
    ans *= factor[i]+1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
e = [0] * (N + 1)
MOD = 10 ** 9 + 7
for i in range(1, N + 1):
    K = i
    for j in range(2, i + 1):
        while K % j == 0:
            e[j] += 1
            K //= j

ans = 1
for i in range(1, N + 1):
    if e[i] > 0:
        ans *= e[i] + 1
        ans %= MOD

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
def eratosthenes(n):
    is_prime = np.ones((n+1,), dtype=bool)
    is_prime[:2] = False
    for i in range(2,n+1):
        if is_prime[i]:
            is_prime[i*2::i]=False
    return np.arange(n+1)[is_prime]
Ps = eratosthenes(1000)
def divisor(n):
    for p in Ps:
        if p*p>n:return -1
        if n%p==0:return p
def prime_division(n):
    d={}
    while n>1:
        p=divisor(n)
        if p==-1:d[n]=d.get(n,0)+1;break
        else:d[p]=d.get(p,0)+1;n//=p
    return d

N=int(input())
d={}
for i in range(1,N):
  p=prime_division(i+1)
  for k,v in p.items():
    d[k]=d.get(k,0)+v
r=1
for v in d.values():
  r=r*(v+1)%1000000007
print(r)

Submission status: Accepted

Solution code:
import time
import math
def sieve(n):
    prime = []
    limit = math.sqrt(n)
    data = [i for i in range(2, n+1)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


n = int(input())
if n == 1:
    print(1)
    exit()
prime = sieve(n)
ans = 1
for sosu in prime:
    cnt = 0
    for i in range(2, n+1):
        num = i
        while num % sosu == 0:
            num //= sosu 
            cnt += 1
    ans *= (cnt + 1)
print(ans % (10**9 + 7))

Submission status: Accepted

Solution code:
n=int(input())
P=[2]
for i in range(3,n+1):
  flag=1
  for p in P:
    if i%p==0:
      flag=0
  if flag==1:
    P.append(i)
ans=1
for p in P:
  np=0
  x=1
  while p**x<=n:
    np+=n//(p**x)
    x+=1
  ans*=(1+np)
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())

M = 1000000007
#compute all prime number in 1000

def isPrime(x):
    for i in range(2,x):
        if x%i==0:
            return False
    return True

primes = []
cnt = dict()
for i in range(2,1000):
    if isPrime(i):
        primes.append(i)
        cnt[i] = 0
for i in range(2,n+1):
    x = i
    for p in primes:
        if p>x:
            break
        while x%p==0:
            x//=p
            cnt[p]+=1

res = 1

for p,c in cnt.items():
    res = (res*(c+1))%M
print(res)

Submission status: Accepted

Solution code:
import math

N = int(input())

d = {}

def primeFactor(n):
    for i in range(2, int(math.sqrt(n)) + 1):
        while n % i == 0:
            d[i] += 1
            n = n // i
    if n != 1:
        if n in d.keys():
            d[n] += 1
        else:
            d[n] = 1
    #return d

ans = 1
mod = 10**9 + 7

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

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

print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
a = [2]
inf = (10 ** 9) + 7
for i in range(3, n+1, 2):
    ans = 'y'
    for j in range(3, i//2, 2):
        if i % j == 0:
            ans = "n"
            break
    if ans == "y":
        a.append(i)
k = math.factorial(n)
ans = 1
for aa in a:
    t = 0
    while (k % aa == 0):
        if k % aa == 0:
            k = k // aa
            t += 1
    ans = (ans * (t+1)) % inf
print(ans)

Submission status: Accepted

Solution code:
# 写経
import math


N = int(input())
mod = 10**9 + 7
nFact = math.factorial(N)
i = 2
ans = 1


while i * i <= nFact:
    cnt = 1
    # 何個 i が含まれるか調べる
    while nFact % i == 0:
        cnt += 1
        nFact //= i
    ans *= cnt
    i += 1
if nFact != 1:
    ans *= 2


print(ans % mod)

Submission status: Accepted

Solution code:
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)

Submission status: Accepted

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

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = [0]
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            if(num != 1):
                factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return n
    else:
        factor.append(n)
        return factor

def main():
    N = int(input())
    result = 1
    divisor = []

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

    for i in range(2,N+1):
        result = result*(divisor.count(i)+1)

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = input()
mod = 10 ** 9 + 7
num_p = [1] * 1001
p = []
# find p
for i in range(2, N + 1):
  canDivide = True
  for j in range(2, i):
    if i % j == 0:
      canDivide = False
      break
  if canDivide:
    p.append(i)

# factorization
for i in range(2, N + 1):
  for j in p:
    c = 0
    while i % j == 0:
      c += 1
      i /= j
    num_p[j] = (num_p[j] + c) % mod

print reduce(lambda x, y: x * y, num_p) % mod

Submission status: Accepted

Solution code:
n = int(input())
table = {}
def prime_decomposition(n):
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            if not i in table:
                table[i] = 1
                n /= i
            else:
                n /= i
                table[i] += 1
        i+=1
    if n>1:
        if not n in table:
            table[int(n)] = 1
        else:
            table[int(n)] += 1
    return 0
for i in range(1,n+1):
    prime_decomposition(i)
ans = 1
for key in table.keys():
    ans *= (table[key]+1)
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
import math
#(Xの)素数判定
#nが素数なら1,そうでないなら0を返す関数
def is_prime(X):
  if (X == 1): 
    return 0
  for i in range(2, int(math.sqrt(X)) + 1):
   if (X % i) == 0: return 0
  return 1

#(Xの)素因数分解
def prime_factorization(X,Factoring):
 #Factoring = {} #要素[ai,ti] -> X = (a1^t1)*...*(an^tn)
 p,P = 2,X
 if(is_prime(P) == 1): Factoring[P] = 1
 else:
  while(1):
   if(P <= p+1):
     break
   count = 0
   while(X%p == 0):
     X = X//p
     count += 1
   if(count != 0):
    if(p in Factoring): Factoring[p] += count
    else: Factoring[p] = count
   p += 1   
 return Factoring


N = int(input())
A = {}
ans = 1
for i in range(2,N+1):
 A = prime_factorization(i,A)
for k, v in A.items():
 ans = ans*(v+1)
 #k:key, v:value
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
import array
import textwrap
import math
mod = 10 ** 9 + 7
def prime(end, typecode="L"):
    assert end > 1
    # 整数iが素数であるかをis_prime[i]が示す
    # 最初はすべてTrueで初期化しておく
    # 最終的にprimesではなくこれを返してもよい
    is_prime = array.array("B", (True for i in range(end)))
    # 0, 1はいずれも素数ではない
    is_prime[0] = False
    is_prime[1] = False
    # 素数を格納する配列
    primes = array.array(typecode)
    # 篩う
    for i in range(2, end):
        if is_prime[i]:  # iが素数であるとき
            primes.append(i)  # 素数の配列に加える
            for j in range(2 * i, end, i):  # iを超えるiの倍数について
                is_prime[j] = False  # 素数ではないため除外する
    return primes.tolist()

n = int(input())
a = prime(n+1)
ans = 1
for i in a:
  b = 0
  c = i
  while c <= n:
    b += n // c
    c = c * i
  b += 1
  ans *= b
  ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import math

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

N = int(input())
ans = 1
for p in [i for i in range(N+1) if is_prime(i)]:
    e = 0
    for n in range(1, N+1):
        while n % p == 0:
            n //= p
            e += 1
    ans *= e + 1
ans %= 10**9 + 7
print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
ans = 0
s = 0
primes = [2]
i = 3
while i <= N:
    all(i % p != 0 for p in primes) and primes.append(i)
    i += 2
l = [0] * len(primes)
for i, p in enumerate(primes):
    j = 1
    while p ** j <= N:
        l[i] += (N // (p ** j))
        j += 1
ans = 1
for n in l:
    ans *= (n + 1)
print(ans % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())


def era(n):
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    data1 = []
    for d in data:
        data1.append([d, 1])
    return data1


mod = 10 ** 9 + 7
n = ni()
lis = era(n)
for i in range(1, n + 1):
    for j in range(len(lis)):
        if i < lis[j][0]:
            break
        elif i % lis[j][0] == 0:
            count = 0
            m = i
            while(m % lis[j][0] == 0):
                m = m // lis[j][0]
                count += 1
            lis[j][1] += count
ans = 1
for i in range(len(lis)):
    ans *= lis[i][1]
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
n = math.factorial(n)
i = 2
MOD = 10 ** 9 + 7
ans = 1
while i * i <= n:
    cnt = 1
    while n % i == 0:
        cnt += 1
        n //= i
    ans *= cnt
    i += 1

if n != 1:
    ans *= 2

print(ans % MOD)

Submission status: Accepted

Solution code:
N = input()
mod = 10 ** 9 + 7
num_p = [1] * 1001
p = []
# find p
for i in range(2, N + 1):
  canDivide = True
  for j in range(2, i):
    if i % j == 0:
      canDivide = False
      break
  if canDivide:
    p.append(i)

# factorization
for i in range(2, N + 1):
  for j in p:
    c = 0
    target = i
    while target % j == 0:
      c += 1
      target /= j
    num_p[j] = (num_p[j] + c) % mod

print reduce(lambda x, y: x * y, num_p) % mod

Submission status: Accepted

Solution code:
from collections import defaultdict

primes = defaultdict(int)

N = int(input())

import itertools
def prime_factors(n):
    for i in itertools.chain([2], itertools.count(3, 2)):
        if n <= 1:
            break
        while n % i == 0:
            n //= i
            yield i

for i in range(1, N+1):
    for p in prime_factors(i):
        primes[p] += 1

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

Submission status: Accepted

Solution code:
N = int(input())
 
d = {}
for i in range(2,N+1):
    tmp = i
    for j in range(2,N+1): 
        while tmp%j==0:
            tmp //= j
            d[j] = d.get(j,0)+1
            
ans = 1
for k in d:
    ans *= d[k]+1
    ans %= 10**9+7
print(ans)

Submission status: Accepted

Solution code:
from math import*
n=factorial(int(input()))

def dv(n):
    if n==1:
        return 1
    divisorsNum=1
    i=2
    while i*i<=n:
        cnt=1
        while n%i==0:
            cnt+=1
            n//=i
        divisorsNum*=cnt
        i+=1
    return divisorsNum*2
mod=(10**9+7)
print(dv(n)%mod)

Submission status: Accepted

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

for n in range(1,N+1):
    for i in range(2,N+1):
        while n%i==0:
            comp[i]+=1
            n//=i
        if n==1:
            break
MOD=10**9+7
res=1
for c in comp:
    res*=c+1
    res%=MOD
print(res)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
primes = dd(int)
n = int(input())
for i in range(2,n+1):
  for j in range(2,int(i**.5)+2):
    while i%j == 0:
      i //= j
      primes[j] += 1
  if i > 1:
    primes[i] += 1
cnt = 1
mod = 10**9+7
for x in primes:
  cnt *= primes[x]+1
  cnt %= mod
print(cnt)