-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTest results - Codility L08 MinPerimeterRectangle.html
4122 lines (2387 loc) · 142 KB
/
Test results - Codility L08 MinPerimeterRectangle.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
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!-- saved from url=(0049)https://codility.com/demo/results/demo8U4R8V-SFA/ -->
<html class="wf-lato-n3-active wf-lato-n4-active wf-lato-n7-active wf-handlee-n4-active wf-active"><!--<![endif]--><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css">@charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide{display:none !important;}ng\:form{display:block;}</style>
<meta charset="utf-8">
<meta http-equiv="content-language" content="en-gb">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Test results - Codility</title>
<link rel="shortcut icon" href="https://codility.com/static/favicon.ico">
<link href="./Test results - Codility L08 MinPerimeterRectangle_files/css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="./Test results - Codility L08 MinPerimeterRectangle_files/style.css" type="text/css">
<link rel="stylesheet" type="text/css" href="./Test results - Codility L08 MinPerimeterRectangle_files/jquery.jqplot.css">
<link rel="stylesheet" type="text/css" href="./Test results - Codility L08 MinPerimeterRectangle_files/normalize.css">
<link rel="stylesheet" type="text/css" href="./Test results - Codility L08 MinPerimeterRectangle_files/jquery-ui-1.10.3.custom.css">
<link rel="stylesheet" href="./Test results - Codility L08 MinPerimeterRectangle_files/3c1aae0b8f0c.css" type="text/css">
<link rel="stylesheet" href="./Test results - Codility L08 MinPerimeterRectangle_files/0982f0a96daf.css" type="text/css">
<script type="text/javascript" async="" src="./Test results - Codility L08 MinPerimeterRectangle_files/ga.js"></script><script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/jquery-1.10.2.js"></script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/jquery-migrate-1.2.1.js"></script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/jquery-ui-1.10.3.js"></script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/jquery.cookie.js"></script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/raven-jquery-native.min.js"></script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/angular.min.js"></script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/b61f71d10c43.js"></script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/tinymce.min.js"></script>
<script>
Raven.config('https://[email protected]/3').install();
window.RAVEN_INSTALLED = true;
</script>
<script>
var STATIC_URL = "/static/";
var TASK_TYPES_STRING = "coding, algo, bug fixing and SQL";
</script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/dab3b37911a9.js"></script>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/dajaxice.core.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300,400,700%7CHandlee"><script>
WebFont.load({
google: {
families: ['Lato:300,400,700', 'Handlee']
}
});
</script>
<!-- NUX -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-10522543-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- Totango Tracking Code -->
<link type="text/css" rel="stylesheet" href="./Test results - Codility L08 MinPerimeterRectangle_files/highlight_styling.css">
<link type="text/css" rel="stylesheet" href="./Test results - Codility L08 MinPerimeterRectangle_files/jquery.fancybox-1.3.4.css">
<style type="text/css">.jqstooltip { position: absolute;left: 0px;top: 0px;visibility: hidden;background: rgb(0, 0, 0) transparent;background-color: rgba(0,0,0,0.6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";color: white;font: 10px arial, san serif;text-align: left;white-space: nowrap;padding: 5px;border: 1px solid white;z-index: 10000;}.jqsfield { color: white;font: 10px arial, san serif;text-align: left;}</style><script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/tab.js"></script><style type="text/css" media="screen"> #uservoice-dialog { z-index: 100003; display: block; text-align: left; margin: -2em auto 0 auto; position: fixed; } #uservoice-overlay { position: fixed; z-index:100002; width: 100%; height: 100%; left: 0; top: 0; background-color: #000; opacity: 0.7; } #uservoice-overlay p { padding: 5px; color: #ddd; font: bold 14px arial, sans-serif; margin: 0; letter-spacing: -1px; } #uservoice-dialog #uservoice-dialog-close { position: absolute; height: 48px; width: 48px; top: -11px; right: -12px; color: #06c; cursor: pointer; background-position: 0 0; background-repeat: no-repeat; background-color: transparent; } html.dialog-open object, html.dialog-open embed { visibility: hidden; } a#uservoice-dialog-close { background-image: url(https://assets.uvcdn.com/images/widgets/close.png); }</style><style type="text/css" media="screen"> body a#uservoice-feedback-tab, body a#uservoice-feedback-tab:link { background-position: 2px 50% !important; position: fixed !important; top: 45% !important; display: block !important; width: 25px !important; height: 98px !important; margin: -45px 0 0 0 !important; padding: 0 !important; z-index: 100001 !important; background-position: 2px 50% !important; background-repeat: no-repeat !important; text-indent: -9000px; } body a#uservoice-feedback-tab:hover { cursor: pointer; } a#uservoice-feedback-tab { left: 0; background-repeat: no-repeat; background-color: #0066cc; background-image: url(https://assets.uvcdn.com/images/widgets/en/feedback_tab_white.png); border: outset 1px #0066cc; border-left: none; } a#uservoice-feedback-tab:hover { background-color: #f00; border: outset 1px #f00; border-left: none; }</style><style id="style-1-cropbar-clipper">/* Copyright 2014 Evernote Corporation. All rights reserved. */
.en-markup-crop-options {
top: 18px !important;
left: 50% !important;
margin-left: -100px !important;
width: 200px !important;
border: 2px rgba(255,255,255,.38) solid !important;
border-radius: 4px !important;
}
.en-markup-crop-options div div:first-of-type {
margin-left: 0px !important;
}
</style></head>
<!-- lang: -->
<body style=""><div id="uservoice-feedback"><a id="uservoice-feedback-tab" "="" onclick="UserVoice.Popin.show(); return false;" onmouseover="UserVoice.Popin.preload();" href="https://codility.uservoice.com/forums/34245?lang=en">Open Feedback Dialog</a></div>
<div id="pre_footer" style="margin-bottom: -53px;">
<div id="top" class="wrapper clearfix">
<div class="promo-header clearfix">
<a class="promo-button button orange h44 shadow-strong" href="https://codility.com/programmers/" id="a-register-tip1">Training center</a><br>
<small>
Check out Codility training tasks
</small>
</div>
<a id="logo-link" href="https://codility.com/">
<img src="./Test results - Codility L08 MinPerimeterRectangle_files/logo.jpg" alt="Codility - we test coders">
</a>
</div>
<div class="top-under">
<div class="spacer"></div>
<!-- ticket_detail -->
<div class="wrapper" id="nux-report">
<div class="demo-anchor" style="height: 120px;" data-hasqtip="4" aria-describedby="qtip-4"></div>
<div class="spacer"></div>
<div id="ticket-operations">
</div>
<div style="clear:both"></div>
<style type="text/css">
.simple-info { color: #777777; }
.simple-info:hover { color: #333333; }
</style>
<div id="tip-extend-forbidden-while-open" style="display:none">
The EXTEND operation of this ticket is currently forbidden.
A candidate is working on the test.
Please wait until the candidate finishes his/her work
or you may perform 'forced close running' operation to stop it immediately.
Then, EXTEND will be enabled.
</div>
<div id="tip-total-time" style="display:none">
'Total time used' measures the time elapsed between the moment the
candidate opens the respective task and the moment he/she finally
submits it.
</div>
<div id="tip-effective-time" style="display:none">
'Effective time used' measures only the time when the respective task
was visible to the candidate and he/she was effectively working on
it. Hence, the clock stops whenever a candidate switches to another
task, before returning to the original task and finally submitting it.
</div>
<div id="tip-timeline" style="display:none">
Use the controls below to see how the code changed during the test.
Blue segments indicate periods when candidate was working on this
task. Gray arrows mark verification attempts, while blue arrow show
final submission.
</div>
<div id="tip-plots-explanation" style="display:none">
This is a legend for plots below.
They show the comparison of running time per test between candidate's solution and benchmark solution(s).
</div>
<div id="tip-performance-warning" style="display:none">
This solution scored low on correctness, so performance is rather not relevant.
</div>
<div id="tip-score" style="display:none">
The total score represent quality of candidate's solution.
</div>
<div id="tip-analysis" style="display:none">
The detailed evaluation report pinpoints particular problems in the
candidate's solution.
</div>
<div id="tip-demo-end" style="display:none;">
You have completed a Codility demo.
<br>
<a class="small-button tip-button" target="_blank" href="http://twitter.com/?status=I%20scored%20100%25%20in%20%23csharp%20on%20%40Codility%21%0Ahttps%3A//codility.com/demo/take-sample-test/min_perimeter_rectangle/">
Tweet this!
<div class="comment">
I scored 100% in #csharp on @Codility!<br>https://codility.com/demo/take-sample-test/min_perimeter_rectangle/
</div>
</a>
<br>
<a class="small-button tip-button" target="_blank" href="http://eepurl.com/iF40H">
Sign up for our newsletter!
</a>
<br>
<a class="small-button tip-button" target="_blank" href="http://www.facebook.com/Codility">
Like us on Facebook!
</a>
</div>
<div class="ticket-detail">
<div>
<table class="ticket-header">
<tbody><tr>
<td class="ticket-hdr" colspan="3">
<div id="nick_container">
<div id="nick" style="display:block">
<strong>
<span id="nick-value" class="value">
Demo ticket
</span>
</strong>
</div>
</div>
</td>
</tr>
<tr>
<td class="ticket-hdr">
</td><td class="ticket-hdr">
<h4>Session</h4>
<div>
<b>ID:</b> <span id="ticket-id">demo8U4R8V-SFA</span>
</div>
<div id="timelimit-min"><b>Time limit:</b> 120 min.</div>
</td><td class="ticket-hdr">
<h4 id="ticket-status">
Status: closed
</h4>
<div id="ticket-create-date"><b>Created on:</b> 2014-12-20 05:51 UTC</div>
<div id="ticket-start-date"><b>Started on:</b> 2014-12-20 05:51 UTC</div>
<div id="ticket-end-date"><b>Finished on:</b> 2014-12-20 06:01 UTC</div>
</td>
</tr><tr>
<td colspan="3" class="ticket-hdr">
</td>
</tr>
</tbody></table>
<div class="total-score" id="total-result">
<h4>Test score</h4>
<div class="help help-total-result" data-hasqtip="3"></div>
<b>100%</b>
<small>
100
out of 100 points
</small>
</div>
<table class="task-scores">
<tbody><tr>
<th class="task-col">Tasks in test</th>
<th class="partial-col">Correctness</th>
<th class="partial-col">Performance</th>
<th class="score-col">Task score</th>
</tr>
<tr>
<td class="task-col difficulty difficulty-1">
<strong>1</strong>
<img src="./Test results - Codility L08 MinPerimeterRectangle_files/icon-type-algo-24.png" title="algo task">
<a href="https://codility.com/demo/results/demo8U4R8V-SFA/#task-0" title="MinPerimeterRectangle">
MinPerimeterRectangle
</a>
</td>
<td class="partial-col">
<div title="good" class="good ">
<div class="progress-bar">
<div class="filled" style="width: 100.00%"></div>
</div>
<span class="number">100%</span>
</div>
</td>
<td class="partial-col">
<div title="good" class="good ">
<div class="progress-bar">
<div class="filled" style="width: 100.00%"></div>
</div>
<span class="number">100%</span>
</div>
</td>
<td class="score-col">
<div>
100%
</div>
</td>
</tr>
</tbody></table>
<div id="loader" style="display:none">
<img src="./Test results - Codility L08 MinPerimeterRectangle_files/ajax-loader.gif" alt="*">
The solution is being evaluated.
</div>
</div>
<div class="clr"></div>
<script type="text/javascript" src="./Test results - Codility L08 MinPerimeterRectangle_files/slider.js"></script>
<div class="tasks">
<div class="task" id="task-0">
<div class="task-header-wrap diff-1">
<div class="difficulty">
<span><span>easy</span></span>
</div>
<div class="task-header">
<div class="small-score-print">
<span id="task-0-result" class="result">
score:
100 of 100
</span>
<a class="score-stats" href="https://codility.com/tasks/min_perimeter_rectangle/#stats">
<span style="display:none" class="result">100</span>
<span style="display:none" class="max-result">100</span>
<span class="inlinesparkline score-histogram" style="" title="Score histogram"><canvas width="70" height="25" style="display: inline-block; width: 70px; height: 25px; vertical-align: top;"></canvas></span>
</a>
</div>
<div class="task-opener">
1.
<a href="https://codility.com/demo/results/demo8U4R8V-SFA/#" id="task-0-name" class="task-opener">MinPerimeterRectangle</a>
</div>
<span class="task-synopsis">
Find the minimal perimeter of any rectangle whose area equals N.
</span>
</div>
</div>
<div class="task-details task-0-details" style="display: block">
<table class="task-details-table">
<tbody><tr valign="top">
<td class="description-column">
<div class="hdr hdr-dark">Task description</div>
<div id="task-0-text">
<div id="brinza-task-description">
<p>An integer N is given, representing the area of some rectangle.</p>
<p>The <i>area</i> of a rectangle whose sides are of length A and B is A * B, and the <i>perimeter</i> is 2 * (A + B).</p>
<p>The goal is to find the minimal perimeter of any rectangle whose area equals N. The sides of this rectangle should be only integers.</p>
<p>For example, given integer N = 30, rectangles of area 30 are:</p>
<blockquote><ul style="margin: 10px;padding: 0px;"><li>(1, 30), with a perimeter of 62,</li>
<li>(2, 15), with a perimeter of 34,</li>
<li>(3, 10), with a perimeter of 26,</li>
<li>(5, 6), with a perimeter of 22.</li>
</ul>
</blockquote><p>Write a function:</p>
<blockquote><p class="lang-c" style="font-family: monospace; font-size: 9pt; display: none"><tt>
int solution(int N);
</tt></p></blockquote>
<blockquote><p class="lang-cpp" style="font-family: monospace; font-size: 9pt; display: none"><tt>
int solution(int N);
</tt></p></blockquote>
<blockquote><p class="lang-pas" style="font-family: monospace; font-size: 9pt; display: none"><tt>
function solution(N: longint): longint;
</tt></p></blockquote>
<blockquote><p class="lang-java" style="font-family: monospace; font-size: 9pt; display: none"><tt>
class Solution { public int solution(int N); }
</tt></p></blockquote>
<blockquote><p class="lang-py" style="font-family: monospace; font-size: 9pt; display: none"><tt>
def solution(N)
</tt></p></blockquote>
<blockquote><p class="lang-php" style="font-family: monospace; font-size: 9pt; display: none"><tt>
function solution($N);
</tt></p></blockquote>
<blockquote><p class="lang-cs" style="font-family: monospace; font-size: 9pt; display: block"><tt>
class Solution { public int solution(int N); }
</tt></p></blockquote>
<blockquote><p class="lang-js" style="font-family: monospace; font-size: 9pt; display: none"><tt>
function solution(N);
</tt></p></blockquote>
<blockquote><p class="lang-pl" style="font-family: monospace; font-size: 9pt; display: none"><tt>
sub solution { my ($N)=@_; ... }
</tt></p></blockquote>
<blockquote><p class="lang-rb" style="font-family: monospace; font-size: 9pt; display: none"><tt>
def solution(n)
</tt></p></blockquote>
<blockquote><p class="lang-vb" style="font-family: monospace; font-size: 9pt; display: none"><tt>
Private Function solution(N As Integer) As Integer
</tt></p></blockquote>
<blockquote><p class="lang-lua" style="font-family: monospace; font-size: 9pt; display: none"><tt>
function solution(N)
</tt></p></blockquote>
<blockquote><p class="lang-m" style="font-family: monospace; font-size: 9pt; display: none"><tt>
int solution(int N);
</tt></p></blockquote>
<blockquote><p class="lang-scala" style="font-family: monospace; font-size: 9pt; display: none"><tt>
object Solution { def solution(N: Int): Int }
</tt></p></blockquote>
<blockquote><p class="lang-go" style="font-family: monospace; font-size: 9pt; display: none"><tt>
func Solution(N int) int
</tt></p></blockquote>
<p>that, given an integer N, returns the minimal perimeter of any rectangle whose area is exactly equal to N.</p>
<p>For example, given an integer N = 30, the function should return 22, as explained above.</p>
<p>Assume that:</p>
<blockquote><ul style="margin: 10px;padding: 0px;"><li>N is an integer within the range [<span class="number">1</span>..<span class="number">1,000,000,000</span>].</li>
</ul>
</blockquote><p>Complexity:</p>
<blockquote><ul style="margin: 10px;padding: 0px;"><li>expected worst-case time complexity is O(sqrt(N));</li>
<li>expected worst-case space complexity is O(1).</li>
</ul>
</blockquote></div>
<div style="margin-top:5px">
<small>Copyright 2009–2014 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.</small>
</div>
</div>
</td>
<td class="spacer-column"> </td>
<td class="solution-column">
<div class="hdr hdr-dark" style="position:relative">
Solution
<div style="position:absolute;right:10px;top:4px;">
</div>
</div>
<div class="hdr">
<b>Programming language used:</b> <span class="language_used" style="font-weight: normal">C#</span>
</div>
<div class="hdr">
<div class="help help-total-time" data-hasqtip="0"></div>
<b>Total time used: 11 minutes</b>
</div>
<div class="hdr">
<div class="help help-effective-time" data-hasqtip="1"></div>
<b>Effective time used: 11 minutes</b>
</div>
<div class="hdr">
<span class="left">Notes: </span>
<div id="sol-desc-0-container">
<div id="sol-desc-0" style="display:block; text-align : left;">
<span class="value user_notes_right" style="font-weight:normal">
<i>not defined yet</i>
</span>
</div>
</div>
<div class="clr"></div>
</div>
<div class="hdr hdr-dark task-timeline-header">
<div class="help help-timeline" data-hasqtip="2"></div>
Task timeline
</div>
<div id="buttons-0" class="slider-buttons" style="text-align: center; margin-top:.5em;">
<button id="timeline-0-rewind" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title=""><span class="ui-button-icon-primary ui-icon ui-icon-seek-first"></span><span class="ui-button-text"></span></button>
<button id="timeline-0-prev" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title=""><span class="ui-button-icon-primary ui-icon ui-icon-seek-prev"></span><span class="ui-button-text"></span></button>
<button id="timeline-0-play" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title=""><span class="ui-button-icon-primary ui-icon ui-icon-play"></span><span class="ui-button-text"></span></button>
<button id="timeline-0-stop" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title=""><span class="ui-button-icon-primary ui-icon ui-icon-stop"></span><span class="ui-button-text"></span></button>
<button id="timeline-0-next" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title=""><span class="ui-button-icon-primary ui-icon ui-icon-seek-next"></span><span class="ui-button-text"></span></button>
<button id="timeline-0-forward" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title=""><span class="ui-button-icon-primary ui-icon ui-icon-seek-end"></span><span class="ui-button-text"></span></button>
</div>
<div id="solution-slider-container-0" class="solution-slider-container">
<div id="solution-slider-0" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" aria-disabled="false" style="border: 0px;"><a class="ui-slider-handle ui-state-default ui-corner-all" href="https://codility.com/demo/results/demo8U4R8V-SFA/#" style="left: 99.5%;"></a></div>
<div id="solution-timeline-container-0" class="solution-timeline-container">
<div id="task-0-timeline" class="task-timeline" style="top: 4px;"><div class="workbar" style="left: 4.29px; width: 420.42px;" note="1419054677:1419055284"></div><div class="submit-outer outer-verify" note="1419055220" style="left: 380.382355848435px;"><div class="submit-inner inner-verify"></div></div><div class="submit-outer outer-verify" note="1419055234" style="left: 390.07902800659px;"><div class="submit-inner inner-verify"></div></div><div class="submit-outer outer-verify" note="1419055248" style="left: 399.775700164745px;"><div class="submit-inner inner-verify"></div></div><div class="submit-outer outer-verify" note="1419055262" style="left: 409.4723723229px;"><div class="submit-inner inner-verify"></div></div><div class="submit-outer outer-verify" note="1419055279" style="left: 421.246902800659px;"><div class="submit-inner inner-verify"></div></div><div class="submit-outer outer-final" note="1419055284" style="left: 424.71px;"><div class="submit-inner inner-final"></div></div></div></div>
<div style="float:right" id="solution-slider-0-time-end">06:01:24</div>
<div id="solution-slider-0-time-start">05:51:17</div>
</div>
<div id="solution-placeholder-0"><div id="task-0-submit-current" class="task-0-submit submited-print" style="position: absolute;">
<div class="code-container">
<div class="code-header">
Code: 06:01:24 UTC,
cs,
final,
score: <strong>100.00</strong>
</div>
<div class="solution-sourcecode-print white">
<div class="line-numbers">
<a>1</a><a>2</a><a>3</a><a>4</a><a>5</a><a>6</a><a>7</a><a>8</a><a>9</a><a>10</a><a>11</a><a>12</a><a>13</a><a>14</a><a>15</a><a>16</a><a>17</a><a>18</a><a>19</a><a>20</a><a>21</a><a>22</a><a>23</a><a>24</a><a>25</a><a>26</a><a>27</a><a>28</a><a>29</a><a>30</a><a>31</a><a>32</a><a>33</a><a>34</a><a>35</a>
</div>
<div class="code-highlight">
<pre id="code-0-32"><code data-prg-lang="cs" class="language-cs hljs"><span class="line "><span class="hljs-keyword">using</span> System;</span>
<span class="line "><span class="hljs-keyword">using</span> System.Collections.Generic;</span>
<span class="line "><span class="hljs-comment">// you can also use other imports, for example:</span></span>
<span class="line "><span class="hljs-comment">// using System.Collections.Generic;</span></span>
<span class="line "></span>
<span class="line "><span class="hljs-comment">// you can use Console.WriteLine for debugging purposes, e.g.</span></span>
<span class="line "><span class="hljs-comment">// Console.WriteLine("this is a debug message");</span></span>
<span class="line "></span>
<span class="line "><span class="hljs-keyword">class</span> <span class="hljs-title">Solution</span> {</span>
<span class="line "> <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">solution</span><span class="hljs-params">(<span class="hljs-keyword">int</span> N)</span> </span>{ </span>
<span class="line "> <span class="hljs-keyword">int</span> min = <span class="hljs-number">2</span> * (N + <span class="hljs-number">1</span>); <span class="hljs-comment">// maximum</span></span>
<span class="line "> </span>
<span class="line "> <span class="hljs-keyword">int</span> B, temp;</span>
<span class="line "> </span>
<span class="line "> <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> A = <span class="hljs-number">1</span>; A < N; A++)</span>
<span class="line "> {</span>
<span class="line "> <span class="hljs-keyword">if</span> (N % A == <span class="hljs-number">0</span>) <span class="hljs-comment">// divisible</span></span>
<span class="line "> {</span>
<span class="line "> B = N / A;</span>
<span class="line "> temp = <span class="hljs-number">2</span> * (B + A);</span>
<span class="line "> <span class="hljs-keyword">if</span> (temp < min)</span>
<span class="line "> {</span>
<span class="line "> min = temp;</span>
<span class="line "> }</span>
<span class="line "> }</span>
<span class="line "> </span>
<span class="line "> <span class="hljs-keyword">if</span> (A * A >= N) <span class="hljs-comment">// no reason to check</span></span>
<span class="line "> {</span>
<span class="line "> <span class="hljs-keyword">break</span>;</span>
<span class="line "> }</span>
<span class="line "> }</span>
<span class="line "> </span>
<span class="line "> <span class="hljs-keyword">return</span> min;</span>
<span class="line "> }</span>
<span class="line ">}</span>
<span class="line "></span></code></pre>
</div>
</div>
</div>
<div class="analysis">
<div class="hdr hdr-dark">
<div class="help help-analysis" data-hasqtip="11"></div>
Analysis
<div class="clr"></div>
</div>
<div class="hdr detected-time-print">
Detected time complexity:<br><b style="font-size: 200%">O(sqrt(N))</b>
</div>
<table class="tests-table">
<thead>
<tr>
<th>test</th>
<th>time</th>
<th class="plot-header"></th>
<th colspan="2">result</th>
</tr>
</thead>
<thead>
<tr>
<th class="group example" colspan="4">Example tests</th>
</tr>
</thead>
<tbody>
<tr>
<td>
example
<br>
<small>example test</small>
</td>
<td align="right">0.076 s</td>
<td colspan=" 2 ">
<b>OK</b>
</td>
</tr>
</tbody>
<thead>
<tr>
<th class="group func" colspan="4">Correctness tests</th>
</tr>
</thead>
<tbody>
<tr>
<td>
extreme_min
<br>
<small>N = 1 test</small>
</td>
<td align="right">0.060 s</td>
<td colspan=" 2 ">
<b>OK</b>
</td>
</tr>
<tr>
<td>
simple1
<br>
<small>N = 36 test</small>
</td>
<td align="right">0.068 s</td>
<td colspan=" 2 ">
<b>OK</b>
</td>
</tr>
<tr>
<td>
simple2
<br>
<small>N = 48 test</small>
</td>
<td align="right">0.064 s</td>
<td colspan=" 2 ">
<b>OK</b>
</td>
</tr>
<tr>
<td>
simple3
<br>
<small>N = 101 test</small>
</td>
<td align="right">0.076 s</td>
<td colspan=" 2 ">
<b>OK</b>
</td>
</tr>
<tr>
<td>
small
<br>
<small>N = 1,234 test</small>
</td>
<td align="right">0.068 s</td>
<td colspan=" 2 ">
<b>OK</b>
</td>
</tr>
</tbody>
<thead>
<tr>
<th class="group perf" colspan="4">Performance tests</th>
</tr>
</thead>
<tbody>
<tr>
<td>
medium
<br>
<small>N = 4,564,320 test</small>
</td>
<td align="right">0.060 s</td>
<td colspan=" 1 ">
<b>OK</b>
</td>
</tr>
<tr>
<td>
prime1
<br>
<small>N = 15,486,451 test</small>