Answer to Question #346022 in Python for Sai

Question #346022

Triples with Properties


Shikhar has two integers S and T. Now, he wants to count al possible triplets of non-negative integers (a, b, c) which satisfy


the below conditions:


-a+b+c<= S -axbxc<=T


Your task is to help him by finding the count of such triplets of non negative integers (a, b, c)


reture cont


T


13 printfomet trip


Input


The only line of input contains two space separated integers S and T


Output


Print the count of triplets of non-pegative integers (a, b, c) satisfying the conditions


Explanation


In the first example, we have $1 and T. O eve 4 triplets of non-negative integers which have the above properties (0,0,0) (0,01), (010) and (100) Therefore, the output is 4


Esc FrLock


2


4


12


4+


1
Expert's answer
2022-05-30T15:14:47-0400

If the only condition is -a+b+c<= S -axbxc<=T

print("Enter S and T")
s, t = [ int(i) for i in input().split() ]
count = 0;
for a in range(t):
    for b in range(t-a):
        for c in range(t-(a+b) ):
            if(b+c-a<=s-a*b*c<=t):
                count+=1;
print(count)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS