Computer Science, asked by sumitranjan049, 1 month ago

1685
Given a list numberListI of integer numbers
that have size N and one another number N2,
of the
Ben Vorven the size S(integer
aber N2
present in every non overlapping subset of size
Sin numberList[). If number N2 is present in
every subset print 1 otherwise print 0.
For Example:
Example-1:
Input:
Value of N i.e. size of numberList[]).
{20,1,6,8,13,20,1,7,20,13,16,20}
6 values of
numberList[]. Each values Parated by a new
line.
16
20 - value of N2
value of Si.e. size of subset.
Output:
1
168
Explanation:​

Answers

Answered by Anonymous
0

The Iternet is a vast network that connects computers all over the world. Through the Internet, people can share information and communicate from anywhere with a Internet connection.

Answered by 485golu
0

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int N =sc.nextInt();

int numberList[]=new int[N];

for(int i=0;i<N;i++){

numberList[i]=sc.nextInt();

}

int N2 =sc.nextInt();

int s =sc.nextInt();

int x=N/s;

int c=0;

int y=N%s;

for(int i=0;i<(N-y);i=i+3){

if(numberList[i]==N2 || numberList[i+1]==N2 ||numberList[i+2]==N2)

c++;

}

System.out.println(c);

if(x==c)

System.out.println(1);

else

System.out.println(0);

}

}

Similar questions