Computer Science, asked by hareeshyarlagadda, 8 hours ago

Problem Statement
You are given three integers N, M and X. You want to calculate the number of arrays A of size N, that satisfy the
following conditions:
The sum of elements of the array is equal to M, I. e A1 + A2 + A3 + .. + AN = M
The bitwise xor of the elements of the array is equal to X, ie A1 A2 A3 ^_^ An = X. Here denotes
bitwise xor operation.
Since the answer can be very large return it modulo 109 + 7
Input Format
The first line contains an integer, N, denoting the number of elements in an array
The next line contains an integer, M. denoting the sum of elements in an array
The next llae contains an integer X, denoting the bitwise-xor of the elements in an array​

Answers

Answered by aayushkumar987186319
0

Answer:

your message and the other side of things to say thank you for your help

Explanation:

Good afternoon my janam how are you I love you too my janam

for more information about the best time

Answered by dreamrob
0

Program in Java:

import java.util.*;

public class MyClass

{

   public static void main(String args[])

   {

       Scanner Sc = new Scanner(System.in);

       int N, M, X;

       System.out.print("Enter number of elements in an array : ");

       N = Sc.nextInt();

       System.out.print("\nEnter the sum of elements in an array : ");

       M = Sc.nextInt();

       System.out.print("\nEnter the bitwise-xor of the elements in an array : ");

       X = Sc.nextInt();

       System.out.print("\nEnter total number of arrays : ");

       int n = Sc.nextInt();

       int A[][] = new int[n][N];

       for(int i = 0; i < n; i++)

       {

           System.out.println("\nEnter elements in the array "+ (i+1));

           for(int j = 0; j < N; j++)

           {

               A[i][j] = Sc.nextInt();

           }

       }

       int c = 0;

       for(int i = 0; i< n; i++)

       {

           int sum = 0;

           int XOR = 0;

           for(int j = 0; j < N; j++)

           {

               sum = sum + A[i][j];

               XOR = XOR ^ A[i][j];

           }

           if(sum == M && XOR == X)

           {

               c++;

           }

       }

       System.out.print("\nNumber of such arrays : " + c);

   }

}

Output:

Enter number of elements in an array : 3

Enter the sum of elements in an array : 6

Enter the bitwise-xor of the elements in an array : 0

Enter total number of arrays : 3

Enter elements in the array 1

1

2

3

Enter elements in the array 2

4

5

6

Enter elements in the array 3

7

8

9

Number of such arrays : 1

Similar questions