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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
div = 10**9 + 7
a = 1
for i in range (2,n+1) :
  a *= i
print ( a%div)

Submission status: Wrong Answer

Solution code:
3

Submission status: Wrong Answer

Solution code:
import math

n = int(input())

lim = int(math.sqrt(n))

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
prime = callIsPrime(n)

arr = [0] * len(prime)

for i in range(len(prime)):
  j = 1
  while n > prime[i] ** j :
    arr[i] += int(n / prime[i] ** j)
    j += 1
  
ans = 1
for i in arr :
  if i != 0:
    ans *= i+1

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

Submission status: Wrong Answer

Solution code:
import math

n = int(input())

lim = int(math.sqrt(n))

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
prime = callIsPrime(n)

arr = [0] * len(prime)

for i in range(len(prime)):
  j = 1
  while n > prime[i] ** j :
    arr[i] += int(n / prime[i] ** j)
    j += 1
  
ans = 1
for i in arr :
  if i != 0:
    ans *= i+1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

def make_prime_list(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
  
def is_prime(num):
    if num < 2:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        for prime in range(2, num_sqrt + 1):
            if num % prime == 0:
                return False
                break
        return True
      
# 階乗の約数の個数(いうて時間かかるから使わないと思う)
import math
from collections import defaultdict
def search_divisor_num_of_factorial_num(num):
    if num <= 0:
        return 0
    elif num == 1 or num == 2:
        return 1
    else:
        # 素数とその個数を入れていく
        dict_counter = defaultdict(int)
        # メモ用のdict
        dict_memo = defaultdict(list)

        for a_num in range(2, num + 1):
            num_sqrt = math.ceil(math.sqrt(a_num))
            prime_list = make_prime_list(num_sqrt)

            # メモ用のdictに入れるためのkeyを残しておく
            now_num = a_num

            for prime in prime_list:
                while a_num % prime == 0:
                    # メモ内にある場合、そこから全部移して、移し終わったらループを抜ける
                    if a_num in dict_memo:
                        for memo in dict_memo[a_num]:
                            dict_counter[memo] += 1
                            dict_memo[now_num].append(memo)

                        a_num = 1

                    else:
                        dict_counter[prime] += 1
                        dict_memo[now_num].append(prime)
                        a_num //= prime

            if a_num != 1:
                dict_counter[a_num] += 1
                dict_memo[now_num].append(a_num)

        divisor_num = 1
        dict_fact = dict(dict_counter)
        for value in dict_fact.values():
            divisor_num *= (value + 1)

        return divisor_num
      
ans = search_divisor_num_of_factorial_num(N)
print(search_divisor_num_of_factorial_num(N) % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())

def make_prime_list(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
  
def is_prime(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True
  
# 階乗の約数の個数(いうて時間かかるから使わないと思う)
import math
from collections import defaultdict
def search_divisor_num_of_factorial_num(num):
    if num <= 0:
        return 0
    elif num == 1 or num == 2:
        return 1
    else:
        # 素数とその個数を入れていく
        dict_counter = defaultdict(int)
        # メモ用のdict
        dict_memo = defaultdict(list)

        for a_num in range(2, num + 1):
            num_sqrt = math.ceil(math.sqrt(a_num))
            prime_list = make_prime_list(num_sqrt)

            # メモ用のdictに入れるためのkeyを残しておく
            now_num = a_num

            for prime in prime_list:
                while a_num % prime == 0:
                    # メモ内にある場合、そこから全部移して、移し終わったらループを抜ける
                    if a_num in dict_memo:
                        for memo in dict_memo[a_num]:
                            dict_counter[memo] += 1
                            dict_memo[now_num].append(memo)

                        a_num = 1

                    else:
                        dict_counter[prime] += 1
                        dict_memo[now_num].append(prime)
                        a_num //= prime

            if a_num != 1:
                dict_counter[a_num] += 1
                dict_memo[now_num].append(a_num)

        divisor_num = 1
        dict_fact = dict(dict_counter)
        for value in dict_fact.values():
            divisor_num *= (value + 1)

        return divisor_num
print(search_divisor_num_of_factorial_num(N) % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())
def make_prime_list(num):
    if num < 2:
        return []

    prime_list = []
    for prime in range(2, num + 1):
        if is_prime(prime):
            prime_list.append(prime)
    return prime_list
  
def is_prime(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False

    # 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True
  
# 階乗の約数の個数(いうて時間かかるから使わないと思う)
import math
from collections import defaultdict
def search_divisor_num_of_factorial_num(num):
    if num <= 0:
        return 0
    elif num == 1 or num == 2:
        return 1
    else:
        # 素数とその個数を入れていく
        dict_counter = defaultdict(int)
        # メモ用のdict
        dict_memo = defaultdict(list)

        for a_num in range(2, num + 1):
            num_sqrt = math.ceil(math.sqrt(a_num))
            prime_list = make_prime_list(num_sqrt)

            # メモ用のdictに入れるためのkeyを残しておく
            now_num = a_num

            for prime in prime_list:
                while a_num % prime == 0:
                    # メモ内にある場合、そこから全部移して、移し終わったらループを抜ける
                    if a_num in dict_memo:
                        for memo in dict_memo[a_num]:
                            dict_counter[memo] += 1
                            dict_memo[now_num].append(memo)

                        a_num = 1

                    else:
                        dict_counter[prime] += 1
                        dict_memo[now_num].append(prime)
                        a_num //= prime

            if a_num != 1:
                dict_counter[a_num] += 1
                dict_memo[now_num].append(a_num)

        divisor_num = 1
        dict_fact = dict(dict_counter)
        for value in dict_fact.values():
            divisor_num *= (value + 1)

        return divisor_num
print(search_divisor_num_of_factorial_num(N) % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
import math

def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num // pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
    
  return pflist

N = int(input())
pflist = getPrimeFactorsList(math.factorial(N))
pfset = set(pflist)
ans  = 1
for i in pfset:
  ans *= (pflist.count(i) + 1)
  #print(i)
  #print(pflist.count(i))
  
  
#print(pflist)
print(ans / (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
import math

def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num // pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
    
  return pflist

N = int(input())
pflist = getPrimeFactorsList(math.factorial(N))
pfset = set(pflist)
ans  = 1
for i in pfset:
  ans *= (pflist.count(i) + 1)
  #print(i)
  #print(pflist.count(i))
  
  
#print(pflist)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
prime = [0]*(N+1)
ans = 1
for i in range(2,N+1):
    d = 1
    while i > 1:
        d+=1
        while i % d == 0:
            i = i//d
            prime[d]+= 1
for j in range(N):
    ans = ans *(prime[j]+1)%(10**9+7)
print(ans)

Submission status: Wrong Answer

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

prime = [2,3,5,7,11,13,17,19,23,29,31]
cnt = {2:0,3:0,5:0,7:0,11:0,13:0,17:0,19:0,23:0,29:0,31:0}

for n in range(2,N+1):
    for p in prime:
        while n % p == 0:
            n //= p
            cnt[p] += 1

ans = 1
for p in prime:
    ans *= cnt[p] + 1

print(ans % MOD)

Submission status: Wrong Answer

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

prime = [2,3,5,7,11,13,17,19,23,29,31]
cnt = {2:0,3:0,5:0,7:0,11:0,13:0,17:0,19:0,23:0,29:0,31:0}

for n in range(2,N+1):
    for p in prime:
        while n % p == 0:
            n //= p
            cnt[p] += 1

ans = 1
for p in prime:
    ans *= cnt[p] + 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
prime = [2]
Res = 1

for i in range(3, N+1, 2):
    flag = True
    for j in prime:
        if i % j == 0:
            flag = False
            break
    if flag:
        prime.append(i)

div = [0]*len(prime)

for i in range(2, N+1):
    for j in range(len(prime)):
        while i % prime[j] == 0:
            div[j] += 1
            i = i//prime[j]

for i in div:
    Res *= i+1

print(Res)

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import Counter


def calc_prime_factors(n):
    # https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
    """ Returns a array of primes, p < n """
    # assert n >= 2
    sieve = np.ones(n // 2, dtype=np.bool)
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i // 2]:
            sieve[i * i // 2::i] = False
    return np.r_[2, 2 * np.nonzero(sieve)[0][1::] + 1]


n = int(input())
primes_smaller_than_1000 = [x for x in calc_prime_factors(1000)]
primes = []
for num in range(1, n + 1):
    for prime_number in primes_smaller_than_1000:
        while num % prime_number == 0:
            num /= prime_number
            primes.append(prime_number)
counter_primes = Counter(primes)
print(counter_primes)
res = 1
for i in counter_primes.values():
    res *= (i + 1)
    res %= 1000000007
print(res)