Z - Three Numbers Given two numbers K and S. Determine how many different values of X, Y and Z such that (0 < X, Y, Z < K) and X+Y + Z = S.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 22PE
icon
Related questions
Question

Write a program in C++

Z - Three Numbers
Given two numbers K and S. Determine how many different values of X, Y and Z such that
(0 < X, Y, Z < K) and X+Y + Z = S.
Input
Only one line containing two numbers K and S (0 <K< 3000,0 <S< 3K).
Output
Print the answer required above.
Examples
Input
2 1
Output
3
Input
9 4
Output
15
Note
In the first test case all values of X, Y, Z that satisfy the conditions are :
001
010
100
In the second test case all values of X, Y, Z that satisfy the conditions are :
XYZ
XYZ
XYZ
XYZ
004
040
202
310
013
10 3
211
400
022
112
220
130
031
121
301
Transcribed Image Text:Z - Three Numbers Given two numbers K and S. Determine how many different values of X, Y and Z such that (0 < X, Y, Z < K) and X+Y + Z = S. Input Only one line containing two numbers K and S (0 <K< 3000,0 <S< 3K). Output Print the answer required above. Examples Input 2 1 Output 3 Input 9 4 Output 15 Note In the first test case all values of X, Y, Z that satisfy the conditions are : 001 010 100 In the second test case all values of X, Y, Z that satisfy the conditions are : XYZ XYZ XYZ XYZ 004 040 202 310 013 10 3 211 400 022 112 220 130 031 121 301
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning