ManUtd vs RM
Practice
5 (1 votes)
Implementation
Easy
Problem
67% Success 421 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Tomorrow there is a match between Manshester United (ManUtd) and Real Madras (RM). Now, ManUtd fanboy hardik is in depression as his team is in a pretty bad form this season (as in all seasons..:)). Hardik went to Sanket for help. Sanket, being the god, told him that If he solves the below problem, ManUtd will win..!! (Godly powers).

Hardik will be given match statistics of a team. A team can get points based on the result of the match: win, tie or loss. If a team wins, it achieves 5 points, a tie can give 1 point and a loss can give no points (0 points).

Given the total matches that team played and number of points that team earned, output total possible combinations of wins, ties and losses that team could have faced to achieve that total points.

See the sample case for better understanding.

Input format:

First line consist of number of testcases T.

Each of the next T lines consist of two numbers: X (total games played by team) and Y (total points earned).

Output format:

For each case, output one line that contains the total number of combinations of wins, ties and losses that team could have gotten to achieve that total points.

Constraints:

1 <= T <= 10^5

1 <= X <= 10^18

0 <= Y <= 10^18

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:20
173 votes
Tags:
Ad-HocMathematicsOpenApprovedEasyMathamatics
Points:20
10 votes
Tags:
OpenAlgorithmsApprovedEasyMathamatics
Points:20
15 votes
Tags:
Ad-HocBasic ProgrammingOpenApprovedEasyMathamatics