-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutated minions
41 lines (35 loc) · 1.31 KB
/
mutated minions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
public class Main {
// Function to count the number of Wolverine-like minions for each test case
public static int countWolverineMinions(int N, int K, int[] minions) {
int count = 0;
for (int minion : minions) {
// Calculate the new characteristic value after transmogrification
int newValue = minion + K;
// Check if the new value is divisible by 7
if (newValue % 7 == 0) {
count++;
}
}
return count;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Read the number of test cases
int T = scanner.nextInt();
for (int t = 0; t < T; t++) {
// Read N and K for each test case
int N = scanner.nextInt();
int K = scanner.nextInt();
// Read the initial characteristic values of the minions
int[] minions = new int[N];
for (int i = 0; i < N; i++) {
minions[i] = scanner.nextInt();
}
// Call the function to count Wolverine-like minions and print the result
int result = countWolverineMinions(N, K, minions);
System.out.println(result);
}
scanner.close();
}
}