Lorem ipsum dolor sit amet, consectetur adipiscing elit. Test link

new post 7

Problem

Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier — a machine which mutates minions.

Each minion has an intrinsic characteristic value (similar to our DNA), which is an integer. The transmogrifier adds an integer K to each of the minions' characteristic value.

Gru knows that if the new characteristic value of a minion is divisible by 7, then it will have Wolverine-like mutations.

Given the initial characteristic integers of N minions, all of which are then transmogrified, find out how many of them become Wolverine-like.

Please Share this article...

Input Format

The first line contains one integer, T, which is the number of test cases. Each test case is then described in two lines.

The first line contains two integers N and K, as described in the statement.

The next line contains N integers, which denote the initial characteristic values for the minions.

Output Format

For each testcase, output one integer in a new line, which is the number of Wolverine-like minions after the transmogrification.

Constraints

  • All initial characteristic values lie between 1 and 10^5 , both inclusive

Sample

Input
1
5 10
2 4 1 35 1
Output
1

Explanation

After transmogrification, the characteristic values become {12,14,11,45,11}, out of which only 14 is divisible by 7. So only the second minion becomes Wolverine-like.

Solution


#include <bits/stdc++.h>
using namespace std;

#define fin(a, b) for(ll i = a; i < b; i++)
#define fdec(a, b) for(ll i = a; i > b; i--)
#define ll long long
#define vl vector<ll>
#define pb push_back
#define FAST ios::sync_with_stdio(false); cin.tie(0)
const long long M = 1e9 + 7;

// Solution from : Code Radius [ https://radiuscode.blogspot.com/ ]

signed main()
{
    FAST;
    ll t;
    cin >> t;
    while (t--) {
        ll n, k;
        cin >> n >> k;
        vector<ll> v(n);
        for (auto &i: v) cin >> i;
        ll c = 0;
        for (ll i = 0; i < n; i++) {
            v[i] += k;
            if (v[i] % 7 == 0) ++c;
        }
        cout << c << '\n';
    }
 return 0;

}
Please First Try to Solve Problem by Yourself.
I am Devesh Singh, Student in Varanasi India . I like to write blog on technology and ethical hacking and other tricks or solutions to problem that anyone face during using technology and Internet.

Post a Comment

© Code Radius 2. All rights reserved. Distributed by Techy Darshan Distributed by Pro Templates