Sort by

recency

|

15 Discussions

|

  • + 0 comments

    Best I can come up with at 3 am.
    (Python3)

    from functools import reduce
    
    MOD = 1_000_000_007
    
    def _value_of_S_reduce(x:int,y:int)->int:
        return (x+y+x*y) % MOD
    
    def value_of_S(l:list)->int:
        return reduce(_value_of_S_reduce,l)
        
    if __name__=='__main__':
        _ = input()
        print(value_of_S(list(map(int,input().split()))))
    
  • + 0 comments

    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

    return 0;
    

    }

  • + 0 comments

    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

  • + 1 comment

    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.

  • + 0 comments

    My simple solution

    https://github.com/joy-mollick/Problem-Solving-Solutions-Math-Greedy-/blob/master/HackerRank-Tell%20the%20Average.cpp