-
Notifications
You must be signed in to change notification settings - Fork 0
/
src3.html
798 lines (692 loc) · 40.6 KB
/
src3.html
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="X-Csrf-Token" content="701279b87f7559fc2ca5d77e3d573075"/>
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=0.01"/>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery-1.8.3.js"></script>
<script type="application/javascript">
window.standaloneContest = false;
function adjustViewport() {
var screenWidthPx = Math.min($(window).width(), window.screen.width);
var siteWidthPx = 1100; // min width of site
var ratio = Math.min(screenWidthPx / siteWidthPx, 1.0);
var viewport = "width=device-width, initial-scale=" + ratio;
$('#viewport').attr('content', viewport);
var style = $('<style>html * { max-height: 1000000px; }</style>');
$('html > head').append(style);
}
if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
adjustViewport();
}
</script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="profileName" content="c3">
<meta name="google-site-verification" content="OTd2dN5x4nS4OPknPI9JFg36fKxjqY0i1PSfFPv_J90"/>
<meta property="fb:admins" content="100001352546622" />
<meta property="og:image" content="http://st.codeforces.com/s/59146/images/codeforces-telegram-square.png" />
<link rel="image_src" href="http://st.codeforces.com/s/59146/images/codeforces-telegram-square.png" />
<meta property="og:title" content="Problem - 121E - Codeforces"/>
<meta property="og:description" content=""/>
<meta property="og:site_name" content="Codeforces"/>
<meta name="cc" content="0c557a337e69fc14e5e3ea135223f22bcf12e3df"/>
<meta name="utc_offset" content="+03:00"/>
<meta name="verify-reformal" content="f56f99fd7e087fb6ccb48ef2" />
<title>Problem - 121E - Codeforces</title>
<meta name="description" content="Codeforces. Programming competitions and contests, programming community" />
<meta name="keywords" content="programming algorithm contest competition informatics olympiads c++ java graphs vkcup" />
<meta name="robots" content="index, follow" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/font-awesome.min.css" type="text/css" charset="utf-8" />
<link href='//fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Cuprum&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" type="image/png" href="http://st.codeforces.com/s/59146/favicon.png">
<!--CombineResourcesFilter-->
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/prettify.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/clear.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/ttypography.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/problem-statement.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/second-level-menu.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/roundbox.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/datatable.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/table-form.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/topic.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/jquery.jgrowl.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/facebox.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/jquery.wysiwyg.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/jquery.autocomplete.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/codeforces.datepick.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/colorbox.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/jquery.drafts.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/community.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/status.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/css/sidebar-menu.css" type="text/css" charset="utf-8" />
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/prettify/prettify.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/moment.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/pushstream.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.easing.min.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.lavalamp.min.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.jgrowl.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.swipe.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/facebox.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/controls/wysiwyg.colorpicker.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/controls/wysiwyg.table.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/controls/wysiwyg.image.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/controls/wysiwyg.link.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.datepick.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.ie6blocker.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.ba-bbq.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/jquery.drafts.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/sjcl.js"></script>
<script type="text/javascript" src="/scripts/8d23c4da9e5fcf8193dea01bc167717e/en/codeforces-options.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/js/codeforces.js?v=20160131"></script>
<!--/CombineResourcesFilter-->
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/markitup/skins/markitup/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://st.codeforces.com/s/59146/markitup/sets/markdown/style.css" type="text/css" charset="utf-8" />
<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/markitup/jquery.markitup.js"></script>
<script type="text/javascript" src="http://st.codeforces.com/s/59146/markitup/sets/markdown/set.js"></script>
<!--[if IE]>
<style>
#sidebar {
padding-left: 1em;
margin: 1em 1em 1em 0;
}
</style>
<![endif]-->
</head>
<body><span style='display:none;' class='csrf-token' data-csrf='701279b87f7559fc2ca5d77e3d573075'> </span>
<div class="button-up" style="display: none; opacity: 0.7; width: 50px; height:100%; position: fixed; left: 0; top: 0; cursor: pointer; text-align: center; line-height: 35px; color: #d3dbe4; font-weight: bold; font-size: 3.0rem;"><i class="icon-circle-arrow-up"></i></div>
<!-- Codeforces JavaScripts. -->
<script type="text/javascript">
var queryMobile = Codeforces.queryString.mobile;
if (queryMobile === "true" || queryMobile === "false") {
Codeforces.putToStorage("useMobile", queryMobile == "true");
} else {
var useMobile = Codeforces.getFromStorage("useMobile");
if (useMobile === true || useMobile === false) {
if (useMobile != false) {
Codeforces.redirect(Codeforces.updateUrlParameter(document.location.href, "mobile", useMobile));
}
}
}
</script>
<script type="text/javascript">
if (window.parent.frames.length > 0) {
window.stop();
}
</script>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '554666954583323',
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<script type="text/javascript">
$(document).ready(function () {
(function () {
jQuery.expr[':'].containsCI = function(elem, index, match) {
return !match || !match.length || match.length < 4 || !match[3] || (
elem.textContent || elem.innerText || jQuery(elem).text() || ''
).toLowerCase().indexOf(match[3].toLowerCase()) >= 0;
}
}(jQuery));
$.ajaxPrefilter(function(options, originalOptions, xhr) {
var csrf = Codeforces.getCsrfToken();
if (csrf) {
var data = originalOptions.data;
if (originalOptions.data !== undefined) {
if (Object.prototype.toString.call(originalOptions.data) === '[object String]') {
data = $.deparam(originalOptions.data);
}
} else {
data = {};
}
options.data = $.param($.extend(data, { csrf_token: csrf }));
}
});
window.getCodeforcesServerTime = function(callback) {
$.post("/data/time", {}, callback, "json");
}
window.updateTypography = function () {
$("div.ttypography code").addClass("tt");
$("div.ttypography pre>code").addClass("prettyprint").removeClass("tt");
$("div.ttypography table").addClass("bordertable");
prettyPrint();
}
$.ajaxSetup({ scriptCharset: "utf-8" ,contentType: "application/x-www-form-urlencoded; charset=UTF-8", headers: {
'X-Csrf-Token': Codeforces.getCsrfToken()
}});
window.updateTypography();
Codeforces.signForms();
setTimeout(function() {
$(".second-level-menu-list").lavaLamp({
fx: "backout",
speed: 1000
});
}, 0);
Codeforces.countdown();
$("a[rel='photobox']").colorbox();
function showAnnouncements(json) {
//info("j=" + JSON.stringify(json));
if (json.t != "a") {
return;
}
// console.log("Got announcement from channel");
setTimeout(function() {
Codeforces.showAnnouncements(json.d, "en");
}, Math.random() * 500);
}
if (Codeforces.getParticipantChannel()) {
Codeforces.subscribe(Codeforces.getParticipantChannel(), function(json) {
showAnnouncements(json);
});
}
if (Codeforces.getContestChannel()) {
Codeforces.subscribe(Codeforces.getContestChannel(), function(json) {
showAnnouncements(json);
});
}
if (Codeforces.getGlobalChannel()) {
Codeforces.subscribe(Codeforces.getGlobalChannel(), function(json) {
showAnnouncements(json);
});
}
if (Codeforces.getUserChannel()) {
Codeforces.subscribe(Codeforces.getUserChannel(), function(json) {
showAnnouncements(json);
});
}
$(".clickable-title").click(function() {
Codeforces.alert($(this).attr("title"));
}).css("position", "relative").css("bottom", "3px");
Codeforces.reformatTimes();
Codeforces.initializePubSub();
Codeforces.setupSpoilers();
Codeforces.setupTutorials("/data/problemTutorial");
});
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-743380-5']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = (document.location.protocol == 'https:' ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<div id="body">
<div class="side-bell" style="visibility: hidden; display: none; opacity: 0.7; width: 40px; position: fixed; right: 0; top: 0; cursor: pointer; text-align: center; line-height: 35px; color: #d3dbe4; font-weight: bold; font-size: 1.5rem;">
<span class="icon-stack" style="width: 100%;">
<i class="icon-circle icon-stack-base"></i>
<i class="icon-bell-alt icon-light"></i>
</span>
<br/>
<span class="side-bell__count" style="position: relative; top: -10px;"></span>
</div>
<div id="header" style="position: relative;">
<div style="float:left;">
<a href="/"><img src="http://st.codeforces.com/s/59146/images/codeforces-logo-with-telegram.png"/></a>
</div>
<div class="lang-chooser">
<div style="text-align: right;">
<a href="?locale=en"><img src="http://st.codeforces.com/s/59146/images/flags/24/gb.png" title="In English" alt="In English"/></a>
<a href="?locale=ru"><img src="http://st.codeforces.com/s/59146/images/flags/24/ru.png" title="По-русски" alt="По-русски"/></a>
</div>
<div >
<a href="/enter?back=%2Fproblemset%2Fproblem%2F121%2FE">Enter</a>
|
<a href="/register">Register</a>
</div>
</div>
<br style="clear: both;"/>
</div>
<div class="roundbox menu-box" style="">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="roundbox-lb"> </div>
<div class="roundbox-rb"> </div>
<div class="menu-list-container">
<ul class="menu-list main-menu-list">
<li class=""><a href="/">Home</a></li>
<li class=""><a href="/contests">Contests</a></li>
<li class=""><a href="/gyms">Gym</a></li>
<li class="current"><a href="/problemset">Problemset</a></li>
<li class=""><a href="/groups">Groups</a></li>
<li class=""><a href="/ratings">Rating</a></li>
<li class=""><a href="/api/help">API</a></li>
<li class=""><a href="/rcc2017">RCC <img class="icon" src="http://st.codeforces.com/images/icons/cup.png"/></a></li>
<li class=""><a href="/vkcup2017">VK Cup <img class="icon" src="http://st.codeforces.com/images/icons/cup.png"/></a></li>
<li class=""><a href="/hftbattle2017">HFT Battle <img class="icon" src="http://st.codeforces.com/images/icons/cup.png"/></a></li>
<li class=""><a href="/tinkoff2017">Tinkoff Challenge <img class="icon" src="http://st.codeforces.com/images/icons/cup.png"/></a></li>
</ul>
<form method="post" action="/search"><input type='hidden' name='csrf_token' value='701279b87f7559fc2ca5d77e3d573075'/>
<input class="search" name="query" data-isPlaceholder="true" value=""/>
</form>
<br style="clear: both;"/>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("input.search").focus(function () {
if ($(this).attr("data-isPlaceholder") === "true") {
$(this).val("");
$(this).removeAttr("data-isPlaceholder");
}
});
});
</script>
<br style="height: 3em; clear: both;"/>
<div style="position: relative;">
<div id="sidebar">
<div class="roundbox highlight-blue sidebox" style="">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="caption titled">→ Attention
<div class="top-links">
</div>
</div>
<div style="margin: 1em">
Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.
</div>
</div>
<div class="roundbox sidebox" style="">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<table class="rtable ">
<tbody>
<tr>
<th class="left" style="width:100%;"><a style="color: black" href="/contest/121">Codeforces Beta Round #91 (Div. 1 Only)</a></th>
</tr>
<tr>
<td class="left bottom" colspan="1"><span class="contest-state-phase">Finished</span></td>
</tr>
</tbody>
</table>
</div>
<div class="roundbox sidebox" style="">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="caption titled">→ Virtual participation
<div class="top-links">
</div>
</div>
<div>
<div style="margin:1em;font-size:0.8em;">
Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.
</div>
<div style="text-align:center;margin:1em;">
<form action="/contest/121/virtual" method="get">
<input type="submit" name="submit" value="Start virtual contest" style="padding:0 0.5em;">
</form>
</div>
</div>
</div>
<div class="roundbox sidebox" style="">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="caption titled">→ Problem tags
<div class="top-links">
</div>
</div>
<div style="padding: 0.5em;">
<div class="roundbox " style="margin:2px; padding:0 3px 2px 3px; background-color:#f0f0f0;float:left;">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="roundbox-lb"> </div>
<div class="roundbox-rb"> </div>
<span class="tag-box" style="font-size:1.2rem;" title="Heaps, binary search trees, segment trees, hash tables, etc">
data structures
</span>
</div>
<div style="clear:both;text-align:right;font-size:1.1rem;">
<span title="Please login into the Codeforces" class="notice">No tag edit access</span>
</div>
</div>
</div>
<form id="addTagForm" action="/data/problemTags" method="post" style="display:none;"><input type='hidden' name='csrf_token' value='701279b87f7559fc2ca5d77e3d573075'/>
<input name="action" type="hidden" value="addTag"/>
<input name="problemId" type="hidden" value="646"/>
<input name="tagName" type="hidden" value=""/>
</form>
<form id="removeTagForm" action="/data/problemTags" method="post" style="display:none;"><input type='hidden' name='csrf_token' value='701279b87f7559fc2ca5d77e3d573075'/>
<input name="action" type="hidden" value="removeTag"/>
<input name="problemId" type="hidden" value="646"/>
<input name="tagName" type="hidden" value=""/>
</form>
<script type="text/javascript">
$(".tag-box img").click(function () {
var tagName = $(this).attr("value");
Codeforces.confirm("Are you sure you want to remove this tag?", function () {
$("#removeTagForm input[name=tagName]").val(tagName);
$("#removeTagForm").submit();
}, function () {
}, "Yes", "No");
});
$("#addTagLink").click(function () {
$(this).hide();
$("#addTagLabel").show();
return false;
});
$("#addTagSelect").change(function () {
var tagName = $(this).val();
if (tagName === "") {
$("#addTagLabel").hide();
$("#addTagLink").show();
} else {
$("#addTagForm input[name=tagName]").val(tagName);
$("#addTagForm").submit();
}
});
</script>
<style type="text/css">
#new-resource-form tr td {
padding-top: 0.5em;
}
#new-resource-form input:not([type="submit"]) {
font-size: 0.8em;
}
#new-resource-form select {
font-size: 0.8em;
}
</style>
<div class="roundbox sidebox sidebar-menu" style="">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="caption titled">→ Contest materials
<div class="top-links">
</div>
</div>
<ul>
<li>
<span>
<a href="/blog/entry/2948" title="Codeforces Beta Round #91" target="_blank">Announcement</a>
</span>
<span style="float: right;">
<img class="delete-resource-link" resourceId="3581" resourceName="Codeforces Beta Round #91"
resourceManual="true" src="http://st.codeforces.com/s/59146/images/icons/close-10x10.png"
style="position: relative;bottom: -1px;left: 1px;cursor: pointer;"/>
</span>
<div style="clear: both;"></div>
</li>
<li>
<span>
<a href="/blog/entry/2956" title="Tutorial" target="_blank">Tutorial</a>
</span>
<span style="float: right;">
<img class="delete-resource-link" resourceId="4373" resourceName="Tutorial"
resourceManual="true" src="http://st.codeforces.com/s/59146/images/icons/close-10x10.png"
style="position: relative;bottom: -1px;left: 1px;cursor: pointer;"/>
</span>
<div style="clear: both;"></div>
</li>
</ul>
</div></div>
<div id="pageContent" class="content-with-sidebar">
<div class="second-level-menu">
<ul class="second-level-menu-list">
<li class="current selectedLava"><a
href="/problemset">Problems</a></li>
<li><a
href="/problemset/submit">Submit</a></li>
<li><a
href="/problemset/status">Status</a></li>
<li><a
href="/problemset/standings">Standings</a></li>
<li><a
href="/problemset/customtest">Custom test</a></li>
</ul>
</div>
<div class="problemindexholder" problemindex="E">
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">E. Lucky Array</div><div class="time-limit"><div class="property-title">time limit per test</div>4 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p><span class="tex-font-style-it">Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits <span class="tex-font-style-bf">4</span> and <span class="tex-font-style-bf">7</span>. For example, numbers <span class="tex-font-style-bf">47</span>, <span class="tex-font-style-bf">744</span>, <span class="tex-font-style-bf">4</span> are lucky and <span class="tex-font-style-bf">5</span>, <span class="tex-font-style-bf">17</span>, <span class="tex-font-style-bf">467</span> are not.</span></p><p>Petya has an array consisting of <span class="tex-span"><i>n</i></span> numbers. He wants to perform <span class="tex-span"><i>m</i></span> operations of two types: </p><ul> <li> <span class="tex-font-style-it">add <span class="tex-span"><i>l</i></span> <span class="tex-span"><i>r</i></span> <span class="tex-span"><i>d</i></span></span> — add an integer <span class="tex-span"><i>d</i></span> to all elements whose indexes belong to the interval from <span class="tex-span"><i>l</i></span> to <span class="tex-span"><i>r</i></span>, inclusive <span class="tex-span">(1 ≤ <i>l</i> ≤ <i>r</i> ≤ <i>n</i>, 1 ≤ <i>d</i> ≤ 10<sup class="upper-index">4</sup>)</span>; </li><li> <span class="tex-font-style-it">count <span class="tex-span"><i>l</i></span> <span class="tex-span"><i>r</i></span></span> — find and print on the screen how many lucky numbers there are among elements with indexes that belong to the interval from <span class="tex-span"><i>l</i></span> to <span class="tex-span"><i>r</i></span> inclusive <span class="tex-span">(1 ≤ <i>l</i> ≤ <i>r</i> ≤ <i>n</i>)</span>. Each lucky number should be counted as many times as it appears in the interval. </li></ul><p>Petya has a list of all operations. The operations are such that after all additions the array won't have numbers that would exceed <span class="tex-span">10<sup class="upper-index">4</sup></span>. Help Petya write a program that would perform these operations.</p></div><div class="input-specification"><div class="section-title">Input</div><p>The first line contains two integers <span class="tex-span"><i>n</i></span> and <span class="tex-span"><i>m</i></span> (<span class="tex-span">1 ≤ <i>n</i>, <i>m</i> ≤ 10<sup class="upper-index">5</sup></span>) — the number of numbers in the array and the number of operations correspondingly. The second line contains <span class="tex-span"><i>n</i></span> positive integers, none of which exceeds <span class="tex-span">10<sup class="upper-index">4</sup></span> — those are the array numbers. Next <span class="tex-span"><i>m</i></span> lines contain operations, one per line. They correspond to the description given in the statement.</p><p>It is guaranteed that after all operations are fulfilled each number in the array will not exceed <span class="tex-span">10<sup class="upper-index">4</sup></span>.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each operation of the second type print the single number on the single line — the number of lucky numbers in the corresponding interval.</p></div><div class="sample-tests"><div class="section-title">Examples</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre>3 6<br />2 3 4<br />count 1 3<br />count 1 2<br />add 1 3 2<br />count 1 3<br />add 2 3 3<br />count 1 3<br /></pre></div><div class="output"><div class="title">Output</div><pre>1<br />0<br />1<br />1<br /></pre></div><div class="input"><div class="title">Input</div><pre>4 5<br />4 4 4 4<br />count 1 4<br />add 1 4 3<br />count 1 4<br />add 2 3 40<br />count 1 4<br /></pre></div><div class="output"><div class="title">Output</div><pre>4<br />4<br />4<br /></pre></div></div></div><div class="note"><div class="section-title">Note</div><p>In the first sample after the first addition the array will look in the following manner:</p><p><span class="tex-font-style-tt">4 5 6</span></p><p>After the second addition:</p><p><span class="tex-font-style-tt">4 8 9</span></p><p>The second sample after the first addition:</p><p><span class="tex-font-style-tt">7 7 7 7</span></p><p>After the second addition:</p><p><span class="tex-font-style-tt">7 47 47 7</span></p></div></div></div>
</div>
<script type="text/javascript">
$(document).ready(function () {
function endsWith(string, suffix) {
return string.indexOf(suffix, string.length - suffix.length) !== -1;
}
var inputFileDiv = $("div.input-file");
var inputFile = inputFileDiv.text();
var outputFileDiv = $("div.output-file");
var outputFile = outputFileDiv.text();
if (!endsWith(inputFile, "standard input")
&& !endsWith(inputFile, "standard input")) {
inputFileDiv.attr("style", "font-weight: bold");
}
if (!endsWith(outputFile, "standard output")
&& !endsWith(outputFile, "standard output")) {
outputFileDiv.attr("style", "font-weight: bold");
}
var titleDiv = $("div.header div.title");
});
</script>
</div>
</div>
<br style="clear: both;"/>
<div id="footer">
<div><a href="http://codeforces.com/">Codeforces</a> (c) Copyright 2010-2017 Mike Mirzayanov</div>
<div>The only programming contests Web 2.0 platform</div>
<div>Server time: <span class="format-timewithseconds" data-locale="en">May/08/2017 16:30:47</span> (c3).</div>
Desktop version, switch to <a rel="nofollow" class="switchToMobile" href="?mobile=true">mobile version</a>.
</div>
<script type="text/javascript">
$(function() {
$(".switchToMobile").click(function() {
Codeforces.redirect(Codeforces.updateUrlParameter(document.location.href, "mobile", "true"));
return false;
});
$(".switchToDesktop").click(function() {
Codeforces.redirect(Codeforces.updateUrlParameter(document.location.href, "mobile", "false"));
return false;
});
});
</script>
<script type="text/javascript">
$(document).ready(function () {
if ($(window).width() < 1600) {
$('.button-up').css('width', '30px').css('line-height', '30px').css('font-size', '20px');
}
if ($(window).width() >= 1200) {
$ (window).scroll (function () {
if ($ (this).scrollTop () > 100) {
$ ('.button-up').fadeIn();
} else {
$ ('.button-up').fadeOut();
}
});
$('.button-up').click(function () {
$('body,html').animate({
scrollTop: 0
}, 500);
return false;
});
$('.button-up').hover(function () {
$(this).animate({
'opacity':'1'
}).css({'background-color':'#e7ebf0','color':'#6a86a4'});
}, function () {
$(this).animate({
'opacity':'0.7'
}).css({'background':'none','color':'#d3dbe4'});;
});
}
Codeforces.focusOnError();
});
</script>
<div class="userListsFacebox" style="display:none;">
<div style="padding: 0.5em; width: 600px; max-height: 200px; overflow-y: auto">
<div class="datatable"
style="background-color: #E1E1E1; padding-bottom: 3px;">
<div class="lt"> </div>
<div class="rt"> </div>
<div class="lb"> </div>
<div class="rb"> </div>
<div style="padding: 4px 0 0 6px;font-size:1.4rem;position:relative;">
User lists
<div style="position:absolute;right:0.25em;top:0.35em;">
<span style="padding:0;position:relative;bottom:2px;" class="rowCount"></span>
<img class="closed" src="http://st.codeforces.com/s/59146/images/icons/control.png"/>
<span class="filter" style="display:none;">
<img class="opened" src="http://st.codeforces.com/s/59146/images/icons/control-270.png"/>
<input style="padding:0;position:relative;bottom:2px;border:1px solid #aaa;height:17px;font-size:1.3rem;"/>
</span>
</div>
</div>
<div style="background-color: white;margin:0.3em 3px 0 3px;position:relative;">
<div class="ilt"> </div>
<div class="irt"> </div>
<table class="">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
// Create new ':containsIgnoreCase' selector for search
jQuery.expr[':'].containsIgnoreCase = function(a, i, m) {
return jQuery(a).text().toUpperCase()
.indexOf(m[3].toUpperCase()) >= 0;
};
if (window.updateDatatableFilter == undefined) {
window.updateDatatableFilter = function(i) {
var parent = $(i).parent().parent().parent().parent();
$("tr.no-items", parent).remove();
$("tr", parent).hide().removeClass('visible');
var text = $(i).val();
if (text) {
$("tr" + ":containsIgnoreCase('" + text + "')", parent).show().addClass('visible');
} else {
parent.find(".rowCount").text("");
$("tr", parent).show().addClass('visible');
}
var found = false;
var visibleRowCount = 0;
$("tr", parent).each(function () {
if (!found) {
if ($(this).find("th").size() > 0) {
$(this).show().addClass('visible');
found = true;
}
}
if ($(this).hasClass('visible')) {
visibleRowCount++;
}
});
if (text) {
parent.find(".rowCount").text("Matches: " + (visibleRowCount - (found ? 1 : 0)));
}
if (visibleRowCount == (found ? 1 : 0)) {
$("<tr class='no-items visible'><td style=\"text-align:left;\"colspan=\"32\">No items<\/td><\/tr>").appendTo($(parent).find('table'));
}
$(parent).find("tr td").removeClass("dark");
$(parent).find("tr.visible:odd td").addClass("dark");
}
$(".datatable .closed").click(function () {
var parent = $(this).parent();
$(this).hide();
$(".filter", parent).fadeIn(function () {
$("input", parent).val("").focus().css("border", "1px solid #aaa");
});
});
$(".datatable .opened").click(function () {
var parent = $(this).parent().parent();
$(".filter", parent).fadeOut(function () {
$(".closed", parent).show();
$("input", parent).val("").each(function () {
window.updateDatatableFilter(this);
});
});
});
$(".datatable .filter input").keyup(function(e) {
window.updateDatatableFilter(this);
e.preventDefault();
e.stopPropagation();
});
$(".datatable table").each(function () {
var found = false;
$("tr", this).each(function () {
if (!found && $(this).find("th").size() == 0) {
found = true;
}
});
if (!found) {
$("<tr class='no-items visible'><td style=\"text-align:left;\"colspan=\"32\">No items<\/td><\/tr>").appendTo(this);
}
});
// Applies styles to datatables.
$(".datatable").each(function () {
$(this).find("tr:first th").addClass("top");
$(this).find("tr:last td").addClass("bottom");
$(this).find("tr:odd td").addClass("dark");
$(this).find("tr td:first-child, tr th:first-child").addClass("left");
$(this).find("tr td:last-child, tr th:last-child").addClass("right");
});
$(".datatable table.tablesorter").each(function () {
$(this).bind("sortEnd", function () {
$(".datatable").each(function () {
$(this).find("th, td")
.removeClass("top").removeClass("bottom")
.removeClass("left").removeClass("right")
.removeClass("dark");
$(this).find("tr:first th").addClass("top");
$(this).find("tr:last td").addClass("bottom");
$(this).find("tr:odd td").addClass("dark");
$(this).find("tr td:first-child, tr th:first-child").addClass("left");
$(this).find("tr td:last-child, tr th:last-child").addClass("right");
});
});
});
}
});
</script>
</div>
</div>
<script type="application/javascript">
$(function() {
$(".userListMarker").click(function() {
$.post("/data/lists", {action: "findTouched"}, function(json) {
Codeforces.facebox(".userListsFacebox");
var tbody = $("#facebox tbody");
tbody.empty();
for (var i in json) {
tbody.append(
$("<tr></tr>").append(
$("<td></td>").attr("data-readKey", json[i].readKey).text(json[i].name)
)
);
}
Codeforces.updateDatatables();
tbody.find("td").css("cursor", "pointer").click(function() {
document.location = Codeforces.updateUrlParameter(document.location.href, "list", $(this).attr("data-readKey"));
});
}, "json");
});
});
</script>
</body>
</html>