We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Algebra
- Tell the Average
- Discussions
Tell the Average
Tell the Average
Sort by
recency
|
15 Discussions
|
Please Login in order to post a comment
Best I can come up with at 3 am.
(Python3)
my simple c solution***
include
include
include
include
int main() { int n; scanf("%d",&n); long long int a[n]; int i; for(int i=0;i
}
We have to get an average, which is sum(entries)/num(entries). So, ostensibly, we need sum(f(each permutation))/nPn. But the key is to realize that the operations are commutative, associative, and distributive.
So we'll always get the same value S. That means that means our expression reduces to nPn*f(one permutation)/nPn = f(one permutation)
We may as well choose the original permutation. The other thing to help speed up runtime is (a+b)%m = (a%m + b%m)%m
We can expect lots of explanation with examples from various apparel manufacturers topics of maths from here. I think this site offers lots of solved examples from each of the topic. I am looking for further updates from here. Keep up the good work.
My simple solution
https://github.com/joy-mollick/Problem-Solving-Solutions-Math-Greedy-/blob/master/HackerRank-Tell%20the%20Average.cpp