PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000211. Đếm ước giai thừa - nâng cao (Divisors of Factorial (hard))

    ID: 3073 Loại: Thông thường 12000ms 512MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Number TheoryPrime numbersPrime factorizationBasic mathematicsDivisorsModular arithmeticBinary search
HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm ước giai thừa - nâng cao (Divisors of Factorial (hard))

Divisors of Factorial (hard)

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given two integers NN and MM, find the number of positive divisors of N!N!, modulo MM.

The modulus MM is not guaranteed to be prime; the computation must also work for composite moduli. For example, 4!=244!=24 has eight divisors and 8 mod 5=38\bmod5=3. Since NN can approach 10810^8, the factorial cannot be represented explicitly.

Input

The only line contains the integers N,MN,M.

Output

Print an integer in [0,M−1][0,M-1]: the number of positive divisors of N!N! modulo MM.

Subtasks

  • Subtask 1 (20 points): 2≤N≤1002\le N\le 100; 2≤M≤10002\le M\le 1000.
  • Subtask 2 (30 points): 2≤N≤100000002\le N\le 10000000; 2≤M≤1062\le M\le 10^6.
  • Subtask 3 (50 points): 2≤N<1082\le N<10^8; 2≤M<1092\le M<10^9.

Examples

Input

4 5

Output

3

Explanation

4!=24=23⋅314!=24=2^3\cdot3^1 has (3+1)(1+1)=8(3+1)(1+1)=8 divisors. Since 8=1⋅5+38=1\cdot5+3, the required remainder is 33. No modular division is needed, so a composite modulus is permitted.