My issue
Mint totalWays = 0;
for (int n = 1; n <= len ; n++) {
Mint ways = 1;
for (auto& [p, cnt] : v) { // p was the prime number, cnt is the number of times that factor present
ways *= n * power<Mint>(cnt + 1, n - 1) ;
}
totalWays += (ways);
}
cout << totalWays << cline;
While solving this problem I wasted my whole time on the line
ways *= n * power<Mint>(cnt + 1, n - 1) ;
When I was modeling the combination, I modeled my requirement like this.
(Select 1 POSITION out of N Where Cnt number of primes can be assigned) AND (For remaining we can assign maximum of cnt + 1 number of prime factor )
which concluded into the formula for 1 prime like
nC1 * (cnt + 1)^(n - 1) ;
Now I know this is incorrect its having duplicate values also but I need help to understand the issue on my modeling,
according to the statement I provided on top, why the formula does not work.
and also then this formula I have provided calculates exactly what ?
and is there any way to solve it alter my problem modeling and solve it differently like I was trying to , instead of going with the trivial (cnt + 1)^n - cnt^n way ?
PLEASE NOTE : I know the correct solution, what I need is some help to understand how wrong was my modeling statement was.
Problem Link: https://www.codechef.com/problems/ARRAYCOUNT