You have given n positive numbers a1 a2 an and you have to calculate the total sum of floor
Answers
Answered by
9
Given an array of n integers, find the sum of f(a[i], a[j]) of all pairs (i, j) such that (1 <= i < j <= n).
f(a[i], a[j]):
If |a[j]-a[i]| > 1
f(a[i], a[j]) = a[j] - a[i]
Else // if |a[j]-a[i]| <= 1
f(a[i], a[j]) = 0
I hope this will help you
If not then comment me
Anonymous:
wow Bhaiyya...kya answer h
Answered by
8
HEY MATE,
f( a(i),a(j) ) :
if... a(j)-a(I) >1
f ( a(I), a(j) = a(j)- a(I)
Else // if a(j)-a(I)<=1
f(I), f(j) = 0
I HOPE IT'S HELP YOU
f( a(i),a(j) ) :
if... a(j)-a(I) >1
f ( a(I), a(j) = a(j)- a(I)
Else // if a(j)-a(I)<=1
f(I), f(j) = 0
I HOPE IT'S HELP YOU
Similar questions