# ECJN202- Editorial

Author: shrivas7
Tester: sandeep1103
Editorialist: shrivas7

CAKEWALK

# PREREQUISITES:

Basic Mathematics

# EXPLANATION:

The idea is check out whether the total no. of candies is divisible by N , or not. If it is divisible by N then it can be equally distributed among N friends else it is not possible to do so.

# SOLUTIONS:

Setter's Solution
#include <iostream>
using namespace std;

int main() {
int t,n,i,s,r;
cin>>t;
while(t--)
{
cin>>n;
s=0;
for(i=0;i<n;i++)
{
cin>>r;
s+=r;
}
if(s%n==0)
cout<<"Yes\n";
else
cout<<"No\n";
}
return 0;
}
Tester's Solution
#include <bits/stdc++.h>
#define ll long long int
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define scanarr(a,b,c) for( i=b;i<c;i++)cin>>a[i]
#define showarr(a,b,c) for( i=b;i<c;i++)cout<<a[i]<<' '
#define ln cout<<'\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define MAX 100005
using namespace std;
////////////////////////////////////////////////////////////////CODE STARTS HERE////////////////////////////////////////////////////////////////

void solve(){
int n,i,j;
cin>>n;
int sum = 0;

for(i = 0; i < n; ++i){
cin >> j;
sum += j;
}

if(sum%n == 0)
cout << "Yes"<<endl;
else
cout << "No" << endl;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
int t;
cin>>t;
while(t--)
solve();
}
1 Like

if you do in python some hints here:

1. Sum of all candies. #sum(candies)
2. than sum of all candies % number of students.
3, if the reminder is 0 print (“Yes”) else print (“No” )
1 Like