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

new post 7

2 min read

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.

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.

قد تُعجبك هذه المشاركات

  • ProblemIn a coding contest, there are prizes for the top rankers. The prize scheme is as follows:Top 1010 participants receive rupees XX each.Participants with …
  • post 4…
  • ProblemIf Give an integer N . Write a program to obtain the sum of the first and last digits of this number.Input FormatThe first line contains an integer T, the total number of te…
  • ProblemEach contest - there are approximately 1500 - 2000 users who participate for the 1st time and get rated.The Chef wanted to tell new users some tricks for their 1st contest:B…
  •  ProblemChef has N slippers, L of which are left slippers and the rest are right slippers. Slippers must always be sold in pairs, where each pair contains one left and one rig…
  • ProblemIn mathematics, the degree of polynomials in one variable is the highest power of the variable in the algebraic expression with non-zero coefficient.Chef has a pol…

إرسال تعليق