-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathques 2.html
More file actions
131 lines (102 loc) · 3.99 KB
/
ques 2.html
File metadata and controls
131 lines (102 loc) · 3.99 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html>
<head>
<title> Ques 2 </title>
<link href="style2.css" rel="stylesheet" type="text/css">
</head>
<script language="JavaScript">
//disable right click
document.addEventListener('contextmenu', event => event.preventDefault());
//disable inspect shortcuts
document.onkeydown = function(e) {
if(event.keyCode == 123) {
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){
return false;
}
}
</script>
<script type="text/javascript">
window.history.forward();
function noBack() { window.history.forward(); }
window.onbeforeload = function() {return" Your work will be lost." ;};
var i=0;
function myfunc()
{
var a=document.myform.q1.value;
if(i<=3)
{
if(a=="14")
{ alert("You got it right " );
window.location.replace("pass2.html ");
}
else
{i++;
if(i==1)
{ alert("Two more Chances!" );
}
else if(i==2)
{ alert("One more chance!" );
}
}
}
else
{alert("All attempts are used !" );
window.location.replace(" attempts.html ");
}
}
</script>
<body onload="noBack();" onpageshow="if(event.persisted) noBack():" onunload="" ;
background="bgq2.gif">
<header>
<div class="headline">
<h1> <u> <br> Question 2 </u></h1>
</div>
<p> <br>
Captain America shows Sam a multiset of integers. (A multiset is a collection of elements where there can be duplicates). In every move Captain America removes a maximum number from this multiset and divides it by 2 (integer division, which is rounded down).
If after dividing, the number is still positive (greater than 0) he re-inserts it back into the multiset.
Before the start of the game, Captain America shows Sam the numbers in his multiset.
Captain America asks Sam, M questions. The i-th question will be denoted by Q[i], and Sam must find the value of the number Captain America will be dividing (before he performs the division) after Q[i]-1 moves. That is, what is the value of the number on which the Q[i]-th division is performed?
Can you help Sam and answer the queries?<br>
<br>Input
<br>• The first line contains 2 space separated integers N, M denoting the initial size of the multiset and the number of questions respectively.
<br>• The next line contains N space separated integers, the initial elements of the multiset.
<br>• Of the next M lines, the i-th line will contain Q[i].
<br>Output
<br>Output M lines, the i-th of which contains the answer for the i-th query.
<br>Constraints
<br>• 1 ≤ N, M ≤ 106
<br>• The queries are given in chronological order. That is, Q[i] > Q[i-1]
<br>• Every element of the multiset will be a positive integer less than 263
<br>• It's guaranteed that the set will contain at least one element at the time of any query.
<br>Input:
<br>4 6
<br>8 5 3 1
<br>1
<br>2
<br>3
<br>4
<br>5
<br>6
<br>8
<br> <br>What will be the sum of EVEN answers for the above input?
<form name= "myform" action=" " method="post">
<div>
<label for="Solution"> Enter Solution: <br></label>
<input type="text" autocomplete="off" name="q1">
</div>
<div>
<input type="button" class="submit" value="Submit" onclick="myfunc ()">
</div>
</form>
</p>
</header>
</body>
</html>