Screening Test
Screening Test
Screening Test
Problem Description
Isuru Udana, of the best competitive programmer of University of Colombo School of Computing .
He is currently doing a research Internship in california university.Isuru Udana is busy with his
research on prime numbers these days.Once, while roaming in the campus he saw numbers written
in a spiral form and he observed that many prime numbers occur on both the diagonals .
He wants to know what percentage of prime numbers is there on both the diagonals to that of all
the numbers on the diagonal. Your task is to write a program to help Isuru Udana.
Input Format
First line of input contains an integer T, which is the number of test cases.<br>
Next T lines contains an integer which denotes size of the matrix (Size of above matrix is 7).
Output Format
Print the percentage of number of prime numbers on the diagonal to the total numbers on
diagonal, correct to six decimal places.
61.538462
60.000000
java Code
import java.util.Scanner;
int s = sc.nextInt();
System.out.println(String.format("%.6f", dp[s/ 2]));
}
}
}
2 - Problem Title
Problem Description
Nikita is making a colour full Graph as a birthday gift for her boyfriend, a fellow programmer! She
has n integers. She wants to draw an undirected connected graph with N edge Each node is shaded
in either red or black color. We define nr to be the number of red nodes and nb to be the number of
black nodes. No 2 adjacent nodes have the same color.
<br><br>
Last Night before the birthday party, Nikita's mischievous little brother removed the last n-2
number. She is really disappointed because she lost the last n-2 number. She calls you because you
are her best friend. You suggest giving an array on the birthday. Nikita has only 2 numbers among
these n numbers. These numbers are the first 2 numbers in n number. If she gifts simply these 2
numbers as an array, then her boyfriend will be disappointed. Nikita never wants her boyfriend to be
disappointed at a birthday party. You suggest making it a magical array. property of magical:
The shortest array such that bitwise xor of its elements is the first number and the sum of its
elements is the second number . Can you help her to build this array Because you're her best friend
Input Format
The only line contains 2 numbers (which denote First and second number ).
Output Format
If there's no array that satisfies the condition, print the difference of 2 numbers(absolute
difference ) Otherwise:print an integer n representing the length of the desired array. The next
line should contain n __positive__ integers, the array itself. Array must be Sorted
4 10
37
java Code:
import java.util.*;
long x = (v - u) / 2;
else {
System.out.println(2);
long [] arr= new long [2];
arr[0]=x;
arr[1]=(u ^ x) ;
Arrays.sort(arr);
System.out.println(arr[0]+ " " +arr[1]);
}
}
}
3 - Problem Title
Problem Description
This Time is the coronavirus global pandemic. The number of coronavirus patients increases
day to day in Italy. Story of ATK Hospital, ATK's single deluxe room is designed to give
enough space for mobility to the Covid 19 patient and accommodation for one attendant
with attached bathing facilities. The ambience of the room is enhanced by the french
windows that allow abundant natural light. To make you feel more at ease, our single deluxe
rooms are additionally equipped with refrigerators, additional seating and a round table.
For example, if a doctor has expertise of 2(i.e, K=2), he will help recover the 1st patient in 2
seconds, 2nd patient in 4 seconds(2 * K) and 3rd patient in 6 seconds(3 * K) that means to
help recover 3 patients he needs a total of 12 seconds.
For the 4th patient he would need another(4 * K) seconds i.e 8 seconds, thus to help 4
patients recover the minimum time he would need would be 20 seconds and maximum time
needed would be 29 seconds.
Input Format
First line contains N, total Number of Covid 19 patients, In the next line the first integer
denotes the number of doctors M, and M Integer follow in the Next line each denoting
expertise value <b>( k)</b> of doctor
Output Format
Print minimum time needed by M doctors to make N Covid 19 patients healthy in ATK
hospital.
10
1234
Sample TestCase Output
12
java code:
import java.util.*;
}
if (time > mid) {
time = 0;
}
} else {
i++;
mult = 1;
time = 0;
}
}
if (Get_Batches_vaccinated >= nov) {
return true;
} else {
return false;
}
}
}
4 - Problem Title
Friend and Game
Problem Description
Two friends were playing a mind game, the game was as follows :<br>
Both players will get 4-4 chances each, player 1 will always go first, both players takes turn
alternatively . They will roll the dice 8 times and note it, if even number comes that means
__Increasing__ else __Decreasing__, after 8 dice roll will start. so,the game is both players have to
build the string with non repeating digit(1-9), whose value is minimum possible and the follows the
relation . your task is to print final number.
For example, suppose after 2-2 turns they got relation as __Increasing__, __Decreasing__,
__Decreasing__, __Increasing__. In this case final String will contains value from 1 to 5
And will be holding this relation between each consecutive digit, we have to print such minimum
possible String. Here the answer will be __"14325"__.(1,4):__Increasing__, (4,3) :__Decreasing__,
(3,2):__Decreasing__,(2,5):__Increasing__
Input Format
Second line Contains String of length 8, representing value appears on dice after it is rolled.
Output Format
25426251
132456987
JAVA Code
import java.util.*;
if (n >= 9)
return "-1";
int count = 1;
int n = sc.nextInt();
while(n-- >0){
String str = sc.next();
String s = "";
for (int i = 0; i < str.length(); i++) {
if (Character.getNumericValue(str.charAt(i)) % 2 == 0) {
s += "I";
} else {
s += "D";
}
}
str = s;
System.out.println(getMinNumberForPattern(str));
}
}
}