# Random chocolates doubt in editorial

**URL:** <https://discuss.codechef.com/t/random-chocolates-doubt-in-editorial/61375>\
**Category:** editorial\
**Created:** [April 11, 2020, 9:35am UTC](https://discuss.codechef.com/t/random-chocolates-doubt-in-editorial/61375 "2020-04-11T09:35:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nemesis1](https://discuss.codechef.com/user_avatar/discuss.codechef.com/nemesis1/32/222565_2.png) [@nemesis1](https://discuss.codechef.com/u/nemesis1)\
**Post date:** [April 11, 2020, 9:35am UTC](https://discuss.codechef.com/t/random-chocolates-doubt-in-editorial/61375/1 "2020-04-11T09:35:04Z")

</div>

> [@RANDCHCL - Editorial](https://discuss.codechef.com/t/randchcl-editorial/57803):
>
> PROBLEM LINK: [Practice](https://www.codechef.com/problems/RANDCHCL)[Div-1 Contest](https://www.codechef.com/COOK116A/problems/RANDCHCL) Author: [Anik Sarker](https://www.codechef.com/users/imAnik) Tester: [Raja Vardhan Reddy](https://www.codechef.com/users/raja1999) Editorialist: [William Lin](https://www.codechef.com/users/tmwilliamlin)DIFFICULTY: Medium PREREQUISITES: Combinatorics PROBLEM: Given an array W of length N, find the expected score from the following process: Choose an integer k between 1 and N uniformly randomly. Let A be k not necessarily distinct elements chosen uniformly randomly and independently from W. Let B be chosen in the same way as A. The score is \sum\_{i=1}^k \sum\_{j =1}^k \gcd(A\_…

this is the link to the editorial where u can even find link to the problem.  
In editorialist’s approach  
why expected value of gcd(a[i],a[j])\*k^2=score?  
how expected value term comes from score expression?  
Thankyou
