PKDICE - Editorial

Problem Link: Contest Page | CodeChef
Author: @umar_07
Tester: @sharshach
Difficulty: Cakewalk
Prerequisite: None

Explanation:

As it is easily noticeable, no matter what comes up in each dice, the sum will always be in the form 5*k (1<= k <= 11). Maximum possible sum in a single throw= 55, Minimum possible sum in a single throw= 5.

And each student throws both the dice M, so Maximum possible sum in M throws= 55*M, Minimum possible sum in M throws= 5 * M.

So for a sum to exist after M throws:

  1. sum%5 == 0
  2. 5 * M <= sum <= 55 * M

Setter’s Code:

#include <bits/stdc++.h>
#define ll long long int
#define debug(x) cerr << #x << " is " << x << " ";
#define mod 1000000007
#define endl "\n"
#define fast_input ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{
    ll t;
    cin >> t;
    while(t--)
    {
        ll n, m, c=0;
        cin  >> n >> m;
        ll arr[n];
        for(int i=0; i<n; i++)
        {
            cin >> arr[i];
            if(arr[i]>=5*m && arr[i]<=55*m && arr[i]%5==0)
                c++;
        }
        cout << c << endl;
    }
	return 0;
}