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
n=int(input())
waru=10**9+7

li=[]
li2=[]

for i in range(2,n+1):
    tmp=math.factorial(n)
    flag=1
    for j in range(len(li)):
        if i%li[j]==0:
            flag=0
            break
    if flag==1:
        li.append(i)
        li2.append(0)
        while tmp%i==0:
            li2[len(li)-1]+=1
            tmp=tmp//i
ans=1
# print(li)
# print(li2)
for i in range(len(li2)):
    ans*=li2[i]+1
print(ans%waru)

Submission status: Accepted

Solution code:
import math
from collections import defaultdict

N = int(input())

d = defaultdict(int)

def division(n,d):
    flag = True
    tmp = n // 2 + 1
    for num in range(2, tmp):
        while n % num == 0:
            flag = False
            n //= num
            d[num] += 1

    if flag:
        d[n] += 1

    return

for n in range(2,N+1):
    division(n,d)

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

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

Submission status: Accepted

Solution code:
N=int(input())
MOD,D=10**9+7,{}
primes=list(map(int,"2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997".split()))
for i in primes:D[i]=1
for i in range(2,N+1):
    number=i
    while number!=1:
        for prime in primes:
            if number%prime==0:
                D[prime]=D[prime]+1
                number=number//prime
L,ans=list(D.values()),1
for j in L:ans*=j
print(ans%MOD)

Submission status: Accepted

Solution code:
from math import factorial# from math
N = int(input())

def pdwn(n):
    i=2
    z={}
    while i*i<=n:
        while n%i==0:
            n//=i
            z[i] = z.get(i,0) + 1
        i+=1
    if n>1:z[n] = z.get(n,0) + 1
    g = 1
    for y in z.keys():g *= z[y] + 1
    return g

print(pdwn(factorial(N))%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())


sosu = "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997"
ls = list(map(int,sosu.split()))
def solve(n,k,cnt):
    if n%k!=0:
        return cnt
    else:
        return solve(n//k,k,cnt+1)


from collections import defaultdict
d = defaultdict(int)
for i in range(1,n+1):
    for j in ls:
        d[j] += solve(i,j,0)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


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

factors = []
for n in range(2, N + 1):
    factors.extend(get_factors(n))
# https://juken-mikata.net/how-to/mathematics/number-of-divisor.html
# 素数の指数 + 1 の積
#: :type: np.ndarray
counts = np.bincount(factors)
ans = 1
for e in counts[counts > 0]:
    ans = ans * (e + 1) % MOD
print(ans)

Submission status: Accepted

Solution code:
N=int(input())

import math
from collections import defaultdict
d = defaultdict(int)

def trial_division(n,d):
    flg=True
    #2から√n以下の数字で割っていく
    tmp = n//2 + 1
    for num in range(2,tmp):
        while n % num == 0:
            flg=False
            n //= num
            d[num]+=1

    #flgがTrueならそれは素数
    if flg:
        d[n]+=1

    return

for n in range(2,N+1):
    trial_division(n,d)

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

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

Submission status: Accepted

Solution code:
# ABC052C - Factors of Factorial (ARC067C)
def count_divisors(num: int) -> int:
    """
    Compute how many divisors a number has.
    arr (2D array): prime factors and how many times used
    e.g. n = 2^a * 3^b -> [(2, a), (3, b)]
         res = (a + 1) * (b + 1)
    """
    max_prime = 0
    dic = {}  # {prime factor: count}

    # Divide num by 2 as much as possible
    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        dic[max_prime] = cnt

    # num must be odd -> skip even numbers
    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

    # To handle the case when n is prime greater than 2
    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())
ans = 1
mod = 10**9 + 7
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
Sieve = [0]*(N+1)

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

for s in Sieve:
    if s > 0:
        ans *= s+1
        ans %= mod

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = [0] * (n+1)
mod = 1000000007
for i in range(1, n+1):
    num = i
    cnt = 0
    m = 2
    while(num != 1):
        while(num % m == 0):
            cnt += 1
            num /= m
        d[m] += cnt
        m += 1
        cnt = 0
ans = 1
for i in range(1,n+1):
    if(d[i] == 0):
        continue
    #print("i:", i, " value:", d[i])
    ans *= (d[i]+1)
    ans %= mod

print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())

# 素因数分解が必要？
# 約数の個数 N = a^x + b^y +c^z+ ...（a, b, cは素因数）の時、
# 約数の個数は(x+1)*(y+1)*(z+1)*...

factor = dict()
#素因数分解した素因数と個数をリストにしたリストを返す関数
def trial_division(n):
    tmp = int(math.sqrt(n)) + 1
    a = n
    flag = False
    for num in range(2, tmp):
        while a%num == 0:
            a //= num
            if num in factor:
                factor[num] += 1
            else:
                factor[num] = 1
            flag = True
    
    if not flag and n != 1:
        factor[n] = 1
    if flag:
        if a in factor:
            factor[a] += 1
        else:
            factor[a] = 1

    # print (n, factor)
    return True

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

ans = 1
for i in factor:
    if i == 1:
        pass
    else:
        ans *= (factor[i]+1)
print (ans%(7 + 10 ** 9))

Submission status: Accepted

Solution code:
import math
from decimal import *
mod = 10 ** 9 + 7


N = int(input())

sosuu = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
for i in range(2, N+1):
    if i % 2 == 0 or i % 3 == 0 or i == 5 or i % 7 == 0 or i % 11 == 0 or i%13 == 0 or i%17 == 0\
            or i%19 == 0 or i%23 == 0 or i%29 == 0 or i%31 == 0 or i%37 == 0:
        continue
    for j in range(2,i+1):
        if j == i:
            sosuu.append(i)
        if i % j == 0:
            break

soinsuu_num = [0 for i in range(len(sosuu))]

for i in range(1, N+1):
    if i == 1:
        continue
    temp = i
    for j in range(len(sosuu)):
        while temp % sosuu[j] == 0 and temp != 1:
            soinsuu_num[j] += 1
            temp = Decimal(temp) / Decimal(sosuu[j])
        if temp == 1:
            break

ans = 1
for i in soinsuu_num:
    if i != 0:
        ans = ans * (i + 1) % mod

print(ans)

Submission status: Accepted

Solution code:
x=int(input())
def divisor(a):
	cnt=0
	for i in range(1, int(a**0.5)+1):
		if a%i==0:
			cnt+=2
	return cnt
ans=1
mod = 10**9 +7
dic={i:0 for i in range(2,x+1)}
for a in range(2,x+1):
	for i in range(2, int(a**0.5)+1):
		while a%i==0:
			dic[i]+=1
			a//=i
	if a!=1:dic[a]+=1
A=[i for i in dic.values() if i!=0]
ans=1
for i in A:
	ans=ans*(i+1)%mod

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
fact=1
for i in range(2,n+1):
	fact*=i
sieve=[0]*2+[1]*100000
primes=[]
for i,e in enumerate(sieve):
	if sieve[i]==1:
		primes.append(i)
		for j in range(i*2,len(sieve),i):
			sieve[j]=0
ans=1
MOD=10**9+7
for prime in primes:
	if fact%prime==0:
		count=0
		while fact%prime==0:
			fact=fact//prime
			count+=1
		ans=(ans*(count+1))%MOD
print(ans%MOD)

Submission status: Accepted

Solution code:
import math
import random


class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

        :param n:
        :return: boolean
        """
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

        d = n - 1
        while d & 1 == 0:
            d >>= 1

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y * y) % n
                d <<= 1

            if y != n - 1 and d & 1 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes


#prime = Prime()
#prime.find_factors(36610051291281) == {653: 1, 593783: 1, 3: 3, 13: 1, 269: 1}

from collections import Counter

N = int(input())

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

mod = int(1e9+7)
prime = Prime()

solver_dict = {}
for i in range(1,N):
  pre_dict = prime.find_factors(i+1)
  solver_dict = dict(Counter(solver_dict) + Counter(pre_dict))

#print(solver)

lst = list(solver_dict.items())
#print(lst)

ans = 1
for i in range(len(lst)):
  ans = ans * (lst[i][1] + 1) % mod

print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  n=I()

  l=[0]*1001

  for i in range(2,n+1):
    y=getPrimeList(i)
    for x in y:
      l[x]+=1

  sm=1
  for x in l:
    if x!=0:
      sm*=x+1

  return sm%mod

print(main())

Submission status: Accepted

Solution code:
from collections import defaultdict

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

nums = []
for i in range(2, N+1):
    for j in range(2, i+1):
        if i % j == 0:
            if i == j:
                nums.append(i)
            else:
                break

c = 0
count = defaultdict(int)
for i in range(2, N+1):
    for n in nums:
        now = i
        while now % n == 0:
            count[n] += 1
            now //= n

ans = 1
for n in count.values():
    ans = ans * (n+1) % p
print(ans)

Submission status: Accepted

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

p = [True for i in range(n+1)]
ret = 1
for i in range(2, n+1):
    if not p[i]:
        continue
    for j in range(n//i + 1):
        p[i*j] = False
    j = 1
    cnt = 1
    while i**j <= n:
        cnt += n//(i**j)
        j += 1
    ret = (ret * cnt) % MOD
print(ret)

Submission status: Accepted

Solution code:

from math import sqrt
from collections import defaultdict
def furui(N):
    primes = []
    nums = list(range(2,N+100))#探索リスト
    limit = sqrt(N+1)

    while True:
        p = nums[0]
        if p > limit:
            primes += nums
            return primes

        primes.append(p)
        nums = [num for num in nums if num % p != 0]




N = int(input())
DIV = 10**9 + 7
primes = furui(N)
di = defaultdict(lambda :0)
for i in range(2,N+1):
    temp = i
    for p in primes:
        while True:
            if temp % p == 0:
                di[p] += 1
                temp /=p
            else:
                break

ans = 1
for v in di.values():
    ans *= (v+1)

print(ans%DIV)

Submission status: Accepted

Solution code:
import numpy as np

n=int(input())

def fact(m):
    factor1=[0] * m
    for j in range(2,m+1):
        factor = [0] * j
        for i in range(2,int(np.sqrt(j)+2)):
            while j % i == 0:
                j//=i
                factor[i-1]+=1
        factor[j-1]+=1
        for k in range(len(factor)):
            factor1[k]+=factor[k]
    return factor1
ans=1
mod=1000000007
for i in fact(n)[1:]:
    if i!=0:
        ans*=(i+1)
        ans%=mod

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
#k(2~n)について、2~kの素数までで割り切れる回数をカウント

if n==1:
    print(1)
    import sys
    sys.exit()

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

prime_list = primes(n)
prime_cnt = dict([(k,0) for k in prime_list])
from decimal import Decimal

for k in range(2,n+1):
    k = Decimal(k)
    for j in prime_list:
        j=Decimal(j)
        while k%j==0:
            prime_cnt[j]+=1
            k = k/j
        if k==1:
            break

import functools
import operator


print(functools.reduce(operator.mul, [v+1 for v in prime_cnt.values()])%(10**9+7))

Submission status: Accepted

Solution code:
from collections import defaultdict

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of #(each prime factors) of n,
    '''
    result = defaultdict(int)
    if n < 2:
        return result
    while n % 2 == 0:
        result[2] += 1
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            n //= p
            result[p] += 1
        p += 2
    if n > 1:
        result[n] += 1
    return result

N = int(input())
MOD = 10**9 + 7
factors = defaultdict(int)
for i in range(2, N+1):
    fac = prime_factorization(i)
    for p, n in fac.items():
        factors[p] += n
ans = 1
for _, n in factors.items():
    ans = (ans * (n+1)) % MOD
print(ans)

Submission status: Accepted

Solution code:
a=int(input())
yakusuu=[[],[]]

for i in range(2,a+1):
    while not i==1:
        for n in range(2,i+1):
            if i%n==0:
                i=int(i/n)
                if n not in yakusuu[0]:
                    yakusuu[0].append(n)
                    yakusuu[1].append(1)
                else:
                    yakusuu[1][yakusuu[0].index(n)]+=1
                break
count=1
for i in yakusuu[1]:
    count*=i+1

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

Submission status: Accepted

Solution code:
N = int(input())


def so_bunkai(num, dicts):
    N = num
    num = int(num**(1 / 2) // 1)
    for i in range(2, num + 2):
        while N % i == 0:
            N /= i
            if i in dicts:
                dicts[i] += 1
            else:
                dicts[i] = 1
    if N != 1:
        if N in dicts:
            dicts[int(N)] += 1
        else:
            dicts[int(N)] = 1
    return dicts


ans_dict = {}
for i in range(1, N + 1):
    ans_dict = so_bunkai(i, ans_dict)
    
asd = 10**9 + 7
ans = 1
for d in ans_dict:
    ans *= (ans_dict[d] + 1)
    ans %= asd

print(ans)

Submission status: Accepted

Solution code:
import math
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:
        return [n]
    else:
        factor.append(n)
        return factor

mod = 10**9+7        
N = int(input())
di = {}
ans = 1
for i in range(1,N+1):
    l = trial_division(i)
    for j in l:
        if(j in di):
            di[j]+=1
        else:
            di[j]=1
for i in di:
    if(i==1):
        continue
    ans *= (di[i]+1)
    ans %= mod
print(ans)

Submission status: Accepted

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

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

    """考え方
    ・6の約数の個数は？
    6を素因数分解すると
    6 = 2 * 3
    2^(k1) * 3^(k2) （0<= k1,k2 <= 1）の組み合わせが約数（1,2,3,6）

    この約数の個数を求める問題は、「|k1|個のボールと|k2|個のボールを取り出す組み合わせ問題」と同じ。

    というふうに、まず素因数分解をして因数のknをそれぞれ求めて、その組合せの数を求めれば良い。
    """

    dic = {}  # dic[p] := 因数pの個数（ただしp^0も含めたいので初期値は1する）

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

            if num%i == 0:
                num = num / i
                if not i in dic: dic[i] = 1
                dic[i] += 1
                continue
            else:
                i += 1
                continue

    ans = 1
    for key, value in dic.items():
        ans *= value
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

    """考え方
    ・6の約数の個数は？
    6を素因数分解すると
    6 = 2 * 3
    2^(k1) * 3^(k2) （0<= k1,k2 <= 1）の組み合わせの数が約数（1,2,3,6）

    これは、「|k1|個のボールと|k2|個のボールを取り出す組み合わせ問題」と同じ。

    というふうに、まず素因数分解をして因数のknをそれぞれ求めて、その組合せの数を求めれば良い。
    """

    dic = {}

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

            if num%i == 0:
                num = num / i
                if not i in dic: dic[i] = 1
                dic[i] += 1
                continue
            else:
                i += 1
                continue

    ans = 1
    for key, value in dic.items():
        ans *= value
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
def shave(n):
    n_root = int(n**0.5)
    candidate = [i for i in range(3,n+1,2)]
    for i in range(3,n_root+2,2):
        candidate = [ j for j in candidate if j == i or j % i != 0]   
    candidate = [2] + candidate
    return candidate

mod = 10**9+7
n = int(input())
factor_list = shave(n)
lf = len(factor_list)
num_list = [ 0 for i in range(lf) ]

ans = 1

if n > 1:
	k = 0
	for i in factor_list:
		a = i
		
		for j in range(10):
			if a > n:
				break
			else:
				num_list[k] += (n // a)
				a *= i
		k += 1

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

print(ans)

Submission status: Accepted

Solution code:
mod = 10 ** 9 + 7

n = int(input())
mp = {}
memo = [0 for i in range(n+1)]
# 2~Nの素因数の数を数えている
for i in range(2, n+1):
    x = i
    for j in range(2, x+1):
        while x % j == 0:
            x /= j
            if memo[j] == 0:
                mp[j] = 0
                memo[j] = 1
            mp[j] += 1

ans = 1
for v in mp.values():
    ans = ans * (v+1)

print(ans % mod)

Submission status: Accepted

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


MOD = 1000000007

def fact(n):
  ret = defaultdict(lambda:0)
  m = 2
  while n > 1:
    if n%m == 0:
      ret[m] += 1
      n //= m
    else:
      m += 1
  return ret


N = int(input())
dct = defaultdict(lambda:0)
for i in range(1,N+1):
  dct_i = fact(i)
  for r in dct_i:
    dct[r] += dct_i[r]

ans = 1
for k in dct:
  ans = (ans*(dct[k]+1)) % MOD
print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  l=[0]*1001

  n=I()

  for i in range(2,n+1):
    x=getPrimeList(i)
    for j in x:
      l[j]+=1

  sm=1
  for i in l:
    sm*=i+1

  return sm%mod

print(main())

Submission status: Accepted

Solution code:
import math
N = int(input())
N_kaizyo = math.factorial(N)
sosuu_list = []
count = 1
ans = 1
def check_sosuu(x):
    i = math.floor(math.sqrt(x))
    for j in range(2,i + 1):
        if (x % j == 0):
            return False

    return True

for i in range(2, N + 1):
    if (check_sosuu(i)):
        sosuu_list.append(i)

for sosuu in sosuu_list:
    while N_kaizyo % sosuu == 0:
        N_kaizyo //= sosuu
        count += 1
    ans *= count
    count = 1

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

Submission status: Accepted

Solution code:
N = int(input())
numberlist = []
for i in range(2, N+1):
	numberlist.append(i)
prime = []
while numberlist != []:
	newnumberlist = []
	now = numberlist.pop(0)
	prime.append(now)
	while numberlist != []:
		x = numberlist.pop(0)
		if x%now != 0:
			newnumberlist.append(x)
	numberlist = newnumberlist
counter = []
for i in range(0, len(prime)):
	counter.append(1)
for i in range(1, N+1):
	m = i
	for j in range(0, len(prime)):
		if m == 1: break
		while m%prime[j] == 0:
			counter[j] += 1
			m = m // prime[j]
ans = 1
for i in range(0, len(counter)):
	ans = (ans*counter[i]) % 1000000007
print(ans)

Submission status: Accepted

Solution code:
import math

n=int(input())
num=[2,3]
for j in range(4,1000):
  for i in range(2,int(math.sqrt(j)+1)):
    if j%i==0:
      break
  else:
    num.append(j)

l=len(num)
times=[]
for ii in range(l):
  if num[ii]>n:
    break
  else:
    for jj in range(11):
      max=0
      count=0
      if num[ii]**jj>n:
        max=jj
    for k in range(1,max):
      count+=n//num[ii]**k
    times.append(count)
ans=1

for kk in range(len(times)):
  ans*=times[kk]+1
print(ans%1000000007)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000



#素因数分解
from collections import Counter



N = int(input())
table = []

def factorint(N):
    # table = []
    while(N > 1):
        for i in range(2,N+1):
            if N%i == 0:
                while N%i == 0:
                    N = N//i
                    table.append(i)
                break
    return table

for i in range(1,N+1):
    factorint(i)
table_ = Counter(table)

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

print(ans)

Submission status: Accepted

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

import numpy as np
is_prime = np.ones(1001,dtype=np.bool)
is_prime[:2] = 0
for p in range(2,100):
  is_prime[p*p::p] = 0
primes = is_prime.nonzero()[0]

def fact_ord(p,n):
  if n < p:
    return 0
  return fact_ord(p,n//p) + n//p

answer = 1
for p in primes:
  answer *= (fact_ord(p,N)+1)
  answer %= MOD
  
print(answer)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
prime = []
d = [v for v in range(2, N + 1)]
while len(d) > 0:
    p = d[0]
    prime.append(p)

    d = [v for v in d if v % p != 0]
    
def f(n):
    c = 0
    mm = {}
    while n != 1:
        t = prime[c]
        if n % t == 0:
            if mm.get(t) == None:
                mm[t] = 0
            mm[t] += 1
            n = n // t
        else:
            c += 1
    return mm

m = {}
for i in range(2, N + 1):
    t = f(i)
    for k, v in t.items():
        if m.get(k) == None:
            m[k] = 0
        m[k] += v

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

Submission status: Accepted

Solution code:
N = int(input())
t = [0] * (N + 1)

for i in range(2, N + 1):
    x = i
    p = 2
    
    # Calculate divisor
    while x > 1:
        while x % p == 0:
            t[p] += 1
            x //= p
        p += 1
        
ans = 1
for c in t:
    ans = (ans * (c + 1)) % (10 ** 9 + 7)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

primes = [True for i in range(n+1)]
nums = [1 for i in range(n + 1)]
for i in range(2, n + 1):
    if not primes[i]:
        continue
    for j in range(i * 2, n + 1, i):
        primes[j] = False
    x = i
    while x <= n:
        nums[i] += n//x
        x *= i

from functools import reduce
print(reduce(lambda x, y: x*y,nums)%(10**9+7))

Submission status: Accepted

Solution code:
N = int(input())

se = [0,0,1]+[1]*998
n = 2
while n ** 2 <= 1000:
    if se[n]:
        nn = 2*n
        while nn <= 1000:
            se[nn] = 0
            nn += n
    n += 1

prime = [x for x in range(0,1001) if se[x]]

ans = 1

for p in prime:
    nn = N
    d = 0
    while True:
        nn //= p
        if not(nn):
            break
        d += nn
    ans *= (d+1)

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

Submission status: Accepted

Solution code:
import math
import copy

def trial_division(n):
    check = 0
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp+1):
        while n % num == 0:
            n /= num
            factor.append(num)
            check = 1
    #素数チェック
    if check == 0:
        factor.append(n)
    return factor

n = int(input())
ans = 1

div = []
for i in range(2,n+1):
    for j in trial_division(i):
        div.append(j)
        div = list(set(div))

for i in div:
    x = 0
    for j in range(i,n+1):
        num = j
        while num % i == 0:
            x += 1
            num /= i
    ans = (ans*(x+1))%(10**9+7)

print(ans)