#P2768. 珍珠项链
珍珠项链
Description
Xiao L decides to make a unique pearl necklace using kinds of pearls. A pearl necklace is a sequence of pearls, and its length is the number of pearls in the sequence. Now he is very rich and owns pearls of each kind. Two necklaces are considered different if, when laid out straight, their pearls are in different linear orders. Xiao L wonders how many different necklaces of lengths from to he can make. To show wealth, each necklace must use all kinds of pearls. Output the answer modulo .
This should be easy for you! If you can help Xiao L solve this problem, he might give you of his assets!
Input Format
The input contains multiple testdata. The first line is an integer , which is the number of testdata. Each testdata occupies one line and contains two integers and , separated by a space.
Output Format
For each testdata, output exactly one line containing one integer, which is the number of kinds of necklaces.
2
2 1
3 2
2
8
Hint
- 40%: , .
- 100%: , , .
- 70%–100%: time limit ms.
Translated by ChatGPT 5
京公网安备 11011102002149号