Avito Cool Challenge 2018 C. Colorful Bricks 【排列組合】
傳送門:http://codeforces.com/contest/1081/problem/C
C. Colorful Bricks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputOn his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.
There are nn bricks lined in a row on the ground. Chouti has got mm paint buckets of different colors at hand, so he painted each brick in one of those mm colors.
Having finished painting all bricks, Chouti was satisfied. He stood back and decided to find something fun with these bricks. After some counting, he found there are
So as usual, he needs your help in counting how many ways could he paint the bricks. Two ways of painting bricks are different if there is at least one brick painted in different colors in these two ways. Because the answer might be quite big, you only need to output the number of ways modulo