-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoi.html
1451 lines (1151 loc) · 28.7 KB
/
noi.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
<script type="x" id="ch0103/01">
var a = Number(prompt())
var b = Number(prompt())
alert(a + b)
</script>
<script type="x" id="ch0103/02">
var a = Number(prompt())
var b = Number(prompt())
var c = Number(prompt())
alert((a + b) * c)
</script>
<script type="x" id="ch0103/03">
var a = Number(prompt())
var b = Number(prompt())
var c = Number(prompt())
alert( parseInt((a + b) / c))
</script>
<script type="x" id="ch0103/04">
var a = Number(prompt())
var b = Number(prompt())
console.log(parseInt(a/b) , (a%b))
</script>
<script type="x" id="ch0103/05">
var a = Number(prompt())
var b = Number(prompt())
alert((a/b).toFixed(9))
</script>
<script type="x" id="ch0103/06">
var a = Number(prompt())
var b = Number(prompt())
console.log((b * 100/a).toFixed(3) + "%")
</script>
<script type="x" id="ch0103/07">
var x = Number(prompt())
var a = Number(prompt())
var b = Number(prompt())
var c = Number(prompt())
var d = Number(prompt())
alert((a * (x**3) + b * (x * x) + c * x + d).toFixed(7))
</script>
<script type="x" id="ch0103/08">
var a = Number(prompt())
alert((5 * (a - 32)/9).toFixed(5))
</script>
<script type="x" id="ch0103/09">
var r = Number(prompt('输入半径'))
var pi = 3.14159
console.log((2 * r).toFixed(4),(2 * pi * r).toFixed(4),(pi * r * r).toFixed(4))
</script>
<script type="x" id="ch0103/10">
var a = Number(prompt())
var b = Number(prompt())
alert((1/(1/a + 1/b)).toFixed(2))
</script>
<script type="x" id="ch0103/11">
var a = Number(prompt())
var b = Number(prompt())
alert((a - parseInt(a/b)*b).toFixed(4))
</script>
<script type="x" id="ch0103/12">
var a = Number(prompt())
alert((4/3*(Math.PI).toFixed(2)*(a**3)).toFixed(2))
</script>456
<script type="x" id="ch0103/13">
var a = Number(prompt())
var x,y,z
x = parseInt(a % 10) //个位数
y = parseInt((a % 100) / 10) //十位数
z = Math.floor(a/100)//百位数
console.log(x.toString()+y.toString()+z.toString())
</script>
<script type="x" id="ch0103/14">
var a = Number(prompt())
var b = Number(prompt())
alert( Math.ceil(20000/(3.14*(b*b)*a)))
</script>
<script type="x" id="ch0103/15">
var a = Number(prompt())
var b = Number(prompt())
var c = Number(prompt())
alert(a - Math.ceil(c/b))
</script>
<script type="x" id="ch0103/16">
var a = Number(prompt())
var b = Number(prompt())
var c = Number(prompt())
var d = Number(prompt())
alert((Math.sqrt((c-a)*(c-a) + (d-b)*(d-b))).toFixed(3))
</script>
<script type="x" id="ch0103/17">
var x1 = Number(prompt())
var y1 = Number(prompt())
var x2 = Number(prompt())
var y2 = Number(prompt())
var x3 = Number(prompt())
var y3 = Number(prompt())
var a = Math.sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) )
var b = Math.sqrt( (x3-x1)*(x3-x1) + (y3-y1)*(y3-y1) )
var c = Math.sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) )
var p = (a + b +c) / 2 //半周长
alert((Math.sqrt( p*( p - a )*( p - b )*( p - c ) )).toFixed(2))
</script>
<script type="x" id="ch0103/18">
var a1 = Number(prompt())
var a2 = Number(prompt())
var n = Number(prompt())
alert(a1 + (n-1) * (a2 - a1))
</script>
<script type="x" id="ch0103/19">
var a = Number(prompt())
var b = Number(prompt())
alert(a * b)
</script>
<script type="x" id="ch0103/20">
var n = Number(prompt())
alert(2**n)
</script>
<!-- NOI-104 编程基础之逻辑表达式与条件分支 -->
<script type="x" id="ch0104/01">
var N = Number(prompt('输入一个正整数'))
if (N > 0) {
console.log('positive')
}else if(N = 0) {
console.log('zero')
}else {
console.log('negative')
}
</script>
<script type="x" id="ch0104/02">
var N = Number(prompt('输入一个浮点数'))
console.log(Math.abs(N))
</script>
<script type="x" id="ch0104/03">
var N = Number(prompt('输入一个正整数'))
if (N % 2 == 0) {
console.log('even')
}else {
console.log('odd')
}
</script>
<script type="x" id="ch0104/04">
var N = prompt('输入一个正整数')
var NASCII = N.charCodeAt(0)
if (NASCII % 2 == 0) {
console.log('NO')
}else {
console.log('YES')
}
</script>
<script type="x" id="ch0104/05">
var x = Number(prompt('输入一个正整数'))
var y = Number(prompt('输入一个正整数'))
if (x > y) {
console.log('>')
}else if(x = y) {
console.log('=')
}else {
console.log('<')
}
</script>
<script type="x" id="ch0104/06">
var N = Number(prompt('输入一个正整数'))
if (N >= 10 && N <= 99) {
console.log('1')
}else {
console.log('0')
}
</script>
<script type="x" id="ch0104/07">
var lucky = Number(prompt('幸运数量'))
var con = Number(prompt('鼓励数量'))
if (lucky >= 10 || con >= 20) {
console.log('1')
}else {
console.log('0')
}
</script>
<script type="x" id="ch0104/08">
var N = Number(prompt('输入一个正整数'))
if (N % 3 == 0 && N % 5 == 0) {
console.log('YES')
}else {
console.log('NO')
}
</script>
<script type="x" id="ch0104/09">
var N = Number(prompt('输入一个正整数'))
if (N % 3 == 0 && N % 5 == 0 && N % 7 == 0) {
console.log('3 5 7')
}else if(N % 3 == 0 && N % 5 == 0 && N % 7 != 0) {
console.log('3 5')
}else if(N % 3 == 0 && N % 7 == 0 && N % 5 != 0){
console.log('3 7')
}else if(N % 5 == 0 && N % 7 == 0 && N % 3 != 0){
console.log('5 7')
}else if(N % 3 == 0 && N % 5 != 0 && N % 7 != 0){
console.log('3')
}else if(N % 3 != 0 && N % 5 == 0 && N % 7 != 0){
console.log('5')
}else if(N % 3 != 0 && N % 5 != 0 && N % 7 == 0){
console.log('7')
}else if(N % 3 != 0 && N % 5 != 0 && N % 7 != 0){
console.log('n')
}
</script>
<script type="x" id="ch0104/10">
var N = Number(prompt('输入数学成绩'))
var M = Number(prompt('输入语文成绩'))
if (N < 60 || M < 60) {
console.log('1')
}else {
console.log('0')
}
</script>
<script type="x" id="ch0104/11">
var N = Number(prompt('去看展览的日期'))
if (N == 1 || N == 3 || N == 5) {
console.log('NO')
}else {
console.log('YES')
}
</script>
<script type="x" id="ch0104/12">
var N = Number(prompt('一次办事要行走的距离'))
if ((50 + N / 3) > (N / 1.2)) {
console.log('Walk')
}else if((50 + N / 3) == (N / 1.2)) {
console.log('All')
}else {
console.log('Bike')
}
</script>
<script type="x" id="ch0104/13">
var x = Number(prompt('一个浮点数'))
var y = 0
if (x >= 0 && x < 5) {
y = -x + 2.5
}else if(x >= 5 && x < 10) {
y = 2 - 1.5*(x-3)*(x-3)
}else if(x >= 10 && x < 20) {
y = x / 2 - 1.5
}
console.log(y.toFixed(3))
</script>
<script type="x" id="ch0104/14">
var x = Number(prompt('输入邮件重量'))
var i = prompt('是否加急')
var s = 0
if(x < 1000) {
s = 8
}else{
s = 8 + Math.ceil((x - 1000) / 500) * 4
}
if (i == 'n') {
s = s
}else if(i == 'y'){
s = s + 5
}
console.log(s)
</script>
<script type="x" id="ch0104/15">
var x = Number(prompt('输入一个数'))
var y = Number(prompt('输入一个数'))
var z = Number(prompt('输入一个数'))
var max
if (x > y && x > z) {
max = x
}else if(y > x && y > z) {
max = y
}else if(z > x && z > y) {
max = z
}
console.log(max)
</script>
<script type="x" id="ch0104/16">
var x = Number(prompt('输入一个数'))
var y = Number(prompt('输入一个数'))
var z = Number(prompt('输入一个数'))
if (x + y > z || x + z > y || y + z > x) {
console.log('yes')
}else {
console.log('no')
}
</script>
<script type="x" id="ch0104/17">
var year = Number(prompt('输入年份'))
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
console.log('Y')
}else {
console.log('N')
}
</script>
<script type="x" id="ch0104/18">
var x = Number(prompt('输入x坐标'))
var y = Number(prompt('输入y坐标'))
if ((x >= -1 && x <= 1) && (y >= -1 && y <= 1)) {
console.log('yes')
}else {
console.log('no')
}
</script>
<script type="x" id="ch0104/19">
var a = Number(prompt())
var b = Number(prompt())
var op = prompt()
if (op == '+') {
console.log(a + b)
} else if (op == '-') {
console.log(a - b)
} else if (op == '*') {
console.log(a * b)
} else if (op == '/') {
if (b == 0) {
console.log('Divided by zero!')
} else {
console.log(a / b)
}
} else {
console.log('Invalid operator!')
}
</script>
<script type="x" id="ch0104/20">
var a = Number(prompt())
var b = Number(prompt())
var c = Number(prompt())
var delta = b * b - 4 * a * c
var delta = b * b - 4 * a * c
if (delta >= 0) {
var x1 = (-b + Math.sqrt(delta)) / (2 * a)
var x2 = (-b - Math.sqrt(delta)) / (2 * a)
if (delta > 0) {
var result = 'x1=' + x1.toFixed(5) + ';x2=' + x2.toFixed(5)
} else {
var result = 'x1=x2=' + x1.toFixed(5)
}
} else {
delta = -delta
var sDelta = Math.sqrt(delta)
var x1real = -b / (2 * a) // x1的实部
var x1imag = sDelta / (2 * a)// x1的虚部
var x2real = -b / (2 * a) // x1的实部
var x2imag = -sDelta / (2 * a)// x1的虚部
var x1 = x1real.toFixed(5) + (x1imag > 0 ? '+' : '') + x1imag.toFixed(5) + 'i'
var x2 = x2real.toFixed(5) + (x2imag > 0 ? '+' : '') + x2imag.toFixed(5) + 'i'
var result = 'x1=' + x1 + ';x2=' + x2
}
console.log(result)
</script>
<script type="x" id="ch0104/21">
var n = Number(prompt('苹果数量'))
var x = Number(prompt('x小时能吃完一个苹果'))
var y = Number(prompt('y小时后还有几个苹果'))
var s
if (y /x >= n) {
console.log('0')
}else if(y / x < n) {
s = n - Math.ceil(y / x)
console.log(s)
}
</script>
<!-- NOI-105 编程基础之循环控制 -->
<script type="x" id="ch0105/01">
var n = Number(prompt()) //学生个数
var totalAge = 0
for (let index = 1; index <= n; index++) {
var age = Number(prompt('请输入第' + index + '人的年龄'))
totalAge = totalAge + age
}
var average = totalAge / n
console.log(average.toFixed(2))
</script>
<script type="x" id="ch0105/02">
var totaljieyu = 0
for (let index = 1; index <= 12; index++) {
var jieyu = Number(prompt('请输入第' + index + '月的结余'))
totaljieyu = totaljieyu + jieyu
}
var average = (totaljieyu / 12).toFixed(2)
console.log('$' + average)
</script>
<script type="x" id="ch0105/03">
var n = Number(prompt('请输入样本容量'))
var s = 0
for (let index = 1; index <= n; index++) {
var number = Number(prompt('输入第' + index + '个数'))
s = s + number
}
var average = (s / n).toFixed(4)
console.log(average)
</script>
<script type="x" id="ch0105/04">
var n = Number(prompt('请输入样本容量'))
var s = 0 //和
var a = 0 //平均值
for (let index = 0; index < n; index++) {
var t = Number(prompt('第' + index + '个数'))
s = s + t
}
a = s / n
console.log(s)
console.log(a.toFixed(5))
</script>
<script type="x" id="ch0105/05">
var n = Number(prompt('请输入样本容量'))
var max = 0 //最大值
for (let index = 0; index < n; index++) {
var t = Number(prompt('第' + index + '个学生的成绩'))
if (t > max) {
max = t
}
}
console.log(max)
</script>
<script type="x" id="ch0105/06">
var n = Number(prompt('请输入序列长度'))
var max = 1
var min = 1000
for (let index = 0; index < n; index++) {
var t = Number(prompt('请输入序列的第' + index + '个数'))
if(t > max) {
max = t
}
if(t < min) {
min = t
}
}
console.log(max - min)
</script>
<script type="x" id="ch0105/07">
var n = Number(prompt('请输入参加的天数'))
var Sgold = 0
var Ssilver = 0
var Scopper = 0
for (let index = 1; index <= n; index++) {
var gold = Number(prompt('输入第' + index + '天得到的金牌数'))
var silver = Number(prompt('输入第' + index + '天得到的银牌数'))
var copper = Number(prompt('输入第' + index + '天得到的铜牌数'))
Sgold = Sgold + gold
Ssilver = Ssilver + silver
Scopper = Scopper + copper
S = Sgold + Ssilver + Scopper
}
console.log(Sgold,Ssilver,Scopper,S)
</script>
<script type="x" id="ch0105/08">
var n = Number(prompt('多边形为几边形'))
var t = 0 //已知内角的和
var r = 0 //剩下的内角度数
for (let index = 1; index < n; index++) {
var l = Number(prompt('输入第' + index + '个内角的度数'))
t = t + l
}
console.log((n-2) * 180 - t )
</script>
<script type="x" id="ch0105/09">
var m = Number(prompt('请输入m'))
var n = Number(prompt('请输入n'))
var t = m //遍历指针
var end = 0
for (let index = 0; index < n-m+1; index++) {
if (t % 2 === 1) {
end = end + t
}
t = t + 1
}
console.log(end)
</script>
<script type="x" id="ch0105/10">
var m = Number(prompt('请输入m'))
var n = Number(prompt('请输入n'))
var t = m //遍历指针
var end = 0
for (let index = 0; index < n-m+1; index++) {
if (t % 17 === 0) {
end = end + t
}
t = t + 1
}
console.log(end)
</script>
<script type="x" id="ch0105/11">
var k = Number(prompt('有多少个正整数')) //k个数
var k1 = 0
var k5 = 0
var k10 = 0
for (let index = 0; index < k; index++) {
var s = Number(prompt('输入的第' + index + '个数'))
if(s === 1) {
k1 = k1 + 1
}
if (s === 5) {
k5 = k5 + 1
}
if (s === 10) {
k10 = k10 +1
}
}
console.log(k1,k5,k10)
</script>
<script type="x" id="ch0105/12">
var N = Number(prompt('整数序列的长度'))
var m = Number(prompt('指定的数字'))
var end = 0 //相同的个数
for (let index = 0; index < N; index++) {
var x = Number(prompt('输入第' + index + '个数'))
if (x === m) {
end++
}
}
console.log(end)
</script>
<script type="x" id="ch0105/13">
var a = Number(prompt('输入整数'))
var n = Number(prompt('几次幂'))
console.log(a ** n)
</script>
<script type="x" id="ch0105/14">
var x = Number(prompt('人口数'))
var n = Number(prompt('年数'))
for (let index = 0; index < n; index++) {
x = x * 1.001
}
console.log(x.toFixed(4))
</script>
<script type="x" id="ch0105/15">
var rate = Number(prompt())
var money = Number(prompt())
var year = Number(prompt())
var ratio = (1 + rate / 100)
for (var i = 0; i < year; i++) {
money = money * ratio
}
console.log(Math.floor(money))
</script>
<script type="x" id="ch0105/16">
var n = Number(prompt())
var result = (1 / Math.sqrt(5)) * (((1 + Math.sqrt(5)) / 2) ** n - ((1 - Math.sqrt(5)) / 2) ** n )
console.log(result)
</script>
<script type="x" id="ch0105/17">
var n = Number(prompt())
var a = 0
var b = 1
var c
for (var i = 0; i < n; i++) {
c = a + b
a = b
b = c
}
console.log(a)
</script>
<script type="x" id="ch0105/18">
var n = Number(prompt())
var baseTotal = Number(prompt())
var baseEffect = Number(prompt())
var baseEffectRatio = baseEffect / baseTotal * 100
for (var i = 1; i < n; i++) {
var total = Number(prompt())
var effect = Number(prompt())
var ratio = effect / total * 100
if (ratio - baseEffectRatio > 5) {
console.log('better')
} else if (baseEffectRatio - ratio > 5) {
console.log('worse')
} else {
console.log('same')
}
}
</script>
<script type="x" id="ch0105/19">
var n = Number(prompt())
var totalTime = 0
for (var i = 0; i < n; i++) {
var x = Number(prompt())
var y = Number(prompt())
var count = Number(prompt())
var distance = Math.sqrt(x * x + y * y)
var time = distance / 50 * 2 + count * 1.5
totalTime += time
}
console.log(Math.ceil(totalTime))
</script>
<script type="x" id="ch0105/20">
var h = Number(prompt())
var total = 0
for (var i = 0; i < 1; i++) {
total += h
h = h / 2
total += h
}
console.log(total - h, h)
</script>
<script type="x" id="ch0105/21">
var N = Number(prompt('输入一个正整数'))
function s(N) {
if(N == 1){
console.log('End')
return
}
if(N % 2 === 1) {
console.log(N + '*3+1=' + (N * 3 + 1))
s(N * 3 + 1)
}
if(N %2 === 0) {
console.log(N + '/2=' + (N / 2))
s(N / 2)
}
}
s(N)
</script>
<script type="x" id="ch0105/22">
var 手上的钱 = 0
var 存下的钱 = 0
var 不够花 = false
for (var i = 1; i <= 12; i++) {
手上的钱 += 300
var 本月预算 = Number(prompt())
if (手上的钱 < 本月预算) {
console.log(-i)
不够花 = true
break
} else {
手上的钱 -= 本月预算
var 能存下的钱 = 手上的钱 - 手上的钱 % 100
手上的钱 -= 能存下的钱
存下的钱 += 能存下的钱
}
}
if (!不够花) {
console.log(手上的钱 + 存下的钱 * 1.2)
}
</script>
<script type="x" id="ch0105/23">
var m = Number(prompt('库存总量'))
var n = Number(prompt('取药人数'))
var Nodrug = 0
for (let index = 0; index < n; index++) {
var drug = Number(prompt('第' + index + '位病人希望取走的药品数量'))
if (drug <= m) {
m = m - drug
}else {
Nodrug = Nodrug + 1
}
}
console.log(Nodrug)
</script>
<script type="x" id="ch0105/24">
var n = Number(prompt('测量次数'))
var normalhour = 0
for (let index = 0; index < n; index++) {
var syspre = Number(prompt('第' + index + '次收缩压'))
var diapre = Number(prompt('第' + index + '次舒张压'))
if ((syspre >= 90 && syspre <= 140) && (diapre >= 60 && diapre <= 90) ) {
normalhour++
}else if((syspre < 90 || syspre >140) || (diapre < 60 || diapre > 90)) {
normalhour--
}
}
console.log(normalhour)
</script>
<script type="x" id="ch0105/25">
// 81到342之间的数转换成7进制与9进制才都是3位数
for (var x = 81; x <= 342; x++) {
var a7 = x % 7 // 7进制个位数
var b7 = (x - a7) / 7 % 7 // 7进制右数第二位数
var c7 = (x - a7 - b7 * 7) / 7 / 7 % 7 // 7进制右数第三位数
var a9 = x % 9 // 9进制个位数
var b9 = (x - a9) / 9 % 9 // 9进制右数第二位数
var c9 = (x - a9 - b9 * 9) / 9 / 9 % 9 // 9进制右数第三位数
if (a7 == c9 && a9 == c7 && b7 == b9) {
console.log(x)
console.log('' + c7 + b7 + a7)
console.log('' + c9 + b9 + a9)
break
}
}
</script>
<script type="x" id="ch0105/26">
var n = Number(prompt('输入的四位数个数'))
var end = 0
for (let index = 0; index < n; index++) {
var num = Number(prompt('第' + index + '次输入的数'))
var D = parseInt(num % 10); //个位
var A = parseInt((num % 10000) / 1000); //千位
var B = parseInt((num % 1000) / 100); //百位
var C = parseInt((num % 100) / 10); //十位
if ((D - A - B - C) > 0) {
end++
}
}
console.log(end)
</script>
<script type="x" id="ch0105/27">
var K = Number(prompt('请输入整数K'))
var n = 1
var Sn = 0
for (let index = 1; ; index++) {
Sn = Sn + 1 / n
n++
if (Sn > K) {
n--
break;
}
}
console.log(n)
</script>
<script type="x" id="ch0105/28">
var n = Number(prompt())
do {
var d = n % 10
console.log(d)
n = n - d
n = n / 10
} while (n > 0)
</script>
<script type="x" id="ch0105/29">
var n = Number(prompt())
var sign = 1
if (n < 0) { // 如果n小于0,把n转成正数,并记录符号
n = -n
sign = -1
}
var str = ''
do {
var d = n % 10 //d = 3
str = str + d // str = 3
n = n - d // n = 120
n = n / 10 // n = 12
} while (n > 0)
str = parseInt(str, 10) // '2'
if (sign == 1) {
console.log(str)
} else {
console.log(-str)
}
</script>
<script type="x" id="ch0105/30">
var m = Number(prompt('输入正整数'))
var k = Number(prompt('输入正整数'))
var n = m.toString()
function searchStrEach(str, target) {
let sum = 0
for (let key of str) {
if (key == target) {
sum ++
}
}
return sum;
}
if ((searchStrEach(n,'3') == k) && ((m % 19) == 0)) {
console.log('YES')
}else {
console.log('NO')
}
</script>
<script type="x" id="ch0105/31">
var n = Number(prompt('一共有几盏灯'))
var m = Number(prompt('一共有多少人'))
var r = ''
进过if = false
for (var i = 1; i <= n; i++) {
var open = true
for (var j = 1;j <= m ; j++) {
if(i % j == 0) {
open = !open
}
}
if (!open) {
if (!进过if) {
进过if = true
r += i
}else {
r += (',' + i)
}
}
}
console.log(r)
</script>
<script type="x" id="ch0105/32">
var n = Number(prompt())
var a = 1
var b = 2
var sum = 0
for (let i = 0; i < n; i++) {
sum += b / a
var c = a + b
a = b
b = c
}
console.log(sum.toFixed(4))
</script>
<script type="x" id="ch0105/33">