-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathques1.html
More file actions
145 lines (111 loc) · 4.53 KB
/
ques1.html
File metadata and controls
145 lines (111 loc) · 4.53 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<title> Ques 1 </title>
<link href="style2.css" rel="stylesheet" type="text/css">
</head>
<body onload="noBack();" onpageshow="if(event.persisted) noBack():" onunload="" ; onload="examTimer"
background= "coding5.gif">
<header>
</div>
<div class="headline">
<h1> <u> <br> Question 1 </u></h1>
</div>
</div>
<div transbox>
<p>
Iron man likes fighting games a lot. He owns a game called "Fight Club". In this game there are n players playing all the times. Every player has a power level (Ai). Every day one of the following 2 things happen:
<br>• Either one of these players get a power boost of X, now his power level increases by X.
<br>• Or two players X and Y (with power levels Ax ad Ay) fight against each other and if some player is having power level strictly greater than the other then he gets all the power (Ax+Ay) and the power level of the other player becomes 0. If they have equal energies then it's a draw and nothing happens.
<br>The above game continues for d days. Now you have the information of what happened on each day.
<br>• 1 i X : ith player gets power of X.
<br>• 2 U V : means the player U and V fight against each other.
<br>After every day you need to print the maximum power level that ay player has (Note that you just need to print power level, player number does not matter here).
<br>Input
<br>First line will contain 2 integers 'n' and 'd', denoting the number of players in the game and number of days for which the game is played respectively.
<br>Next line contains n integers denoting the initial power levels of all the players.
<br>Next d lines contain one of the 2 operations mentioned above.
<br>Output
<br>Contains 'd' lines with each integer(ith) denoting the Maximum power level after the ith day.
<br>Constraints
<br>• 1 <= n,d <= 10^5
<br>• 1 <= Ai <= 10^9
<br>• 1 <= i, U, V <= n
<br>• 1 <= X <= 10^9
<br>If Input is:
<br>5 5
<br>12 5 2 14 6
<br>1 2 5
<br>2 1 3
<br>1 3 2
<br>2 1 5
<br>2 4 5
<br> Count duplicate answers only once in all the above outputs, and put them in a set named A.
<br>What is the sum of all prime factors of the elements in set A?
<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></div>
</header>
</body>
<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=="16")
{
alert(" You got it right " );
window.location.replace(" pass1.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 ");
}
}
var select = document.getElementById("DropList");
var length = select.options.length;
for (i = 0; i < length; i++) {
select.options[i] = null;
}
</script>
</html>