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+
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)
Comments
Leave a comment