MINION TROUBLE
Practice
0 (0 votes)
Medium
Problem
12% Success 16 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

One day, The well known female Monk also known as Munki, was meditating at the forest. But a minion came and disturbed Munki from her meditation. Now, Munki has decided to curse the minion. The minion got frightened and cried. Now, seeing the cute minion melted the monk's heart and she offered the minion a deal Minion is given a question and minion needs to answer the question else it is trouble on hand. The question is : Minion will be given a single query each containing four integers N,K,L and V. Now the minion needs to find the number of solutions to this equation:

                    (a0 + a1 + a2 ................... +an-1) mod K  = V

                                     Where 0<=ai<=L

Input Only single line of Input contains four integers, N,K,L and V.

Output Output a single line containing the number of solutions to above equation.


Input Constraints:
1<=N<=10^9
1<=K<=100
1<=L<=10^9
0<=V<=K-1

Note: There are N integers, a0 to an-1, and each is a whole number maximum upto L.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
7 votes
Tags:
Dynamic ProgrammingStringRecursionMediumOpenApproved
Points:30
58 votes
Tags:
ReadyMathematicsDynamic ProgrammingMedium
Points:20
368 votes
Tags:
Ad-HocApprovedEasyImplementationReadySorting