2019HUST_ACM邀请赛出题1

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_20669971/article/details/88918386

Problem X Many Balls

Input file: standard input
Output file: standard output
Time limit: 1 seconds
Memory limit: 128MB

Description

You are given three integer numbers: k k , S ( 1 k , S 1 0 18 ) S(1\leq k,S \leq 10^{18}) and a prime number p ( 2 p 5 × 1 0 6 ) p(2\leq p \leq 5\times10^6) ,and we give A n s Ans a definition as following:
A n s = i = 1 k x i [ x i 1 ] [ i = 1 k x i S ] Ans=\sum{\prod_{i=1}^{k}x_i}[x_i\geq1][\sum_{i=1}^kx_i\leq S]
Assumed that P P is a proposition:
[ P ] = { 1 P = t r u e 0 P = f a l s e [P]=\begin{cases} 1 & P=true \\ 0 & P =false \end{cases}
Please output the A n s Ans

Input

Three integer numbers: k k , S ( 1 k , S 1 0 18 ) S(1\leq k,S \leq 10^{18}) and a prime number p ( 2 p 5 × 1 0 6 ) p(2\leq p \leq 5\times10^6)

Output

An integer A n s Ans

Sample

Standard Input Standard Output
2 4 37 15

Note

x 1 x_1 x 2 x_2 x 1 + x 2 x_1+x_2 x 1 × x 2 x_1 \times x_2
1 1 2 1
1 2 3 2
1 3 4 3
2 1 3 2
2 2 4 4
3 1 4 3

A n s = ( 1 + 2 + 3 + 2 + 4 + 3 ) Ans=(1 + 2 + 3 + 2 + 4 + 3) m o d mod 37 37 = 15 =15

猜你喜欢

转载自blog.csdn.net/qq_20669971/article/details/88918386