WCOUNT - WA

problem link
http://www.codechef.com/problems/WCOUNT/

solution proposed n!/(a!*b!*c!..)
I have pre-calculated factorials and its inverse within time limits

solution link (getting WA)
http://www.codechef.com/viewsolution/2526228

Why are you doing this:

for(int i=0;i<12;i++)
cout<<invfact[i]<<endl;

That is not part of the output, right?

2 Likes

in your main function

No, that is not just it.

Why is your invfact designed to hold only 12 inverses? n can be as large as 500 and if all the letters in the word are the same, then a1 can be as large as n, which inturn, can be as large as 500. So, we need to calculate the inverses of upto atleast 500.

You would need to incorporate these changes as well.

2 Likes

given in question that You can also assume that no character repeats more than 10 times in the string.

yes that is not the part of output.
thnks for looking into the code.

Didn’t read that. Only saw the constraints :wink:

1 Like