Question: Tredence Analytics | NIT Jamshedpur | 8th June 2023 | Mystery keys | T-Missing element
1
Entering edit mode

Mystery keys


John has been given a positive integer number N by Alice. Alice is very much fond of keys and loves to collect them,
and now she asks John to find the number of good keys with the given N. A good key is referred to as a
triplet (x, y, z) which satisfies the following constraints:-

  • x,y,z are prime numbers such that 1 ≤ x < y < z ≤ N. 
  • z⊕ y ⊕ x = 0 le. the Bitwise Exclusive-OR of x,y.z is equal to 0

Task


Determine the total number of possible good keys which satisfy
the given conditions.


Example


Assumption

  • N = 5

Approach

 

  • There are good 0 keys that satisfy the above conditions given N = 5
  • So the answer to this sample example becomes 0.

 

Function description


Complete the good_keys function provided in function takes the following parameter and returns an integer that represents the answer to the task as described problem statement:

  • N. Represents the integer given in the problem statement

Input format


Note: This is the input format that you must use
input 

  •  The first line contains an integer N denote parameter N.

Output format


Print an integer denoting the number of good keys for the given task


Constraints


N ≤ 106

 

Approach


There are no good keys satisfying the conditions given in the problem
So the answer to this given input becomes o

Note:


Your code must be able to print the sample output from the provided
sample input However, your code is run against multiple hidden test case
herofore, vour code must pass those noden tost cases to
Limite
Time Lime: 10 secis) for each input
Memory Limit: 256 MB
Source Limit 1024 KB


Scoring

Score is assigned if any test case is passed

 



T-Missing element


You are given 2 arrays A and B each consisting of integers.


Task


Print the smallest number which is present in array A but missing in array sno such element exists print -1


Example


Assumptions

 

  • N = 6
  •  A = [ 1,2,4,6,5,6]
  • B = [ 2,5,8,5,1is,5]

Approach

 

  • Number 4 is present in allay A but missing in array B
  • So the output is 4

Function description


Complete the function solve() which takes three parameters and retums an integer as the required output:

  • N. Represents an integer denoting the sizeof the array
  • A : Represents an array of N integers
  • B : Represents an array of N integers

 

Input Format


Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
The first line contains an integer N.
The second line contains an array A of N integers
The third fine contains an array B of N integers.

 

Output format


Print the smallest numbers which are present in array A but
missing in array B. If no such element exists, print -1.

 

Sample Input                          Sample Output
8                                           22
3 6 7 100 12 22 12 12
12 3 6 100 40 3 50 7

 

Note

Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases
Therefore, your code must pass these hidden test cases to solve the problem statement.


Limits


Time Limit: 10 secs) for each input file
Memory Limit 256 MB
Source Limit: 1024 KB
Scoring
Score is assigned if any testcase pass
 

 

 

 

 

Login before adding your answer.

Similar Posts
Loading Similar Posts