Counting Product Subset Coefficients
Time limit2sMemory limit512 MB
Given huge n (up to 500+ digits) and a prime p, count how many k in [0,n] make the elementary symmetric sum f(n,k) not divisible by p, output the count mod 1e9+7.
- Level
Hard8 of 10
- Topics
- Number theory, Combinatorics, Math, Divide and conquer
- Solved
- No attempts yet
Problem
For integers and , let . The value is the sum, over every -element subset of , of the product of the elements in that subset. In other words,
[ f(n,k)=\sum_{S\subseteq [n],\ |S|=k}\prod_{x\in S}x. ]
Also, .
Given a positive integer and a prime , count how many integers with make not divisible by .
Input
The first line contains an integer and a prime , separated by a space.
Output
Print the number of valid values of , modulo .
Constraints
- is prime