-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblems.xml
More file actions
5740 lines (5508 loc) · 156 KB
/
problems.xml
File metadata and controls
5740 lines (5508 loc) · 156 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
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
<?xml version="1.0" encoding="UTF-8"?>
<fps version="1.2" url="https://github.com/zhblue/freeproblemset/">
<generator name="HUSTOJ" url="https://github.com/zhblue/hustoj/"/>
<item>
<title><![CDATA[A+B 输入输出练习I]]></title>
<time_limit unit="s"><![CDATA[2]]></time_limit>
<memory_limit unit="mb"><![CDATA[32]]></memory_limit>
<description><![CDATA[<p>
你的任务是计算a+b。这是为了acm初学者专门设计的题目。你肯定发现还有其他题目跟这道题的标题类似,这些问题也都是专门为初学者提供的。<span><span style="font-size:14px;"><br />
</span></span>
</p>]]></description>
<input><![CDATA[<p>
输入包含一系列的a和b对,通过空格隔开。一对a和b占一行。<span><span style="font-size:14px;"><br />
</span></span>
</p>]]></input>
<output><![CDATA[<p>
对于输入的每对a和b,你需要依次输出a、b的和。
</p>
<p>
如对于输入中的第二对a和b,在输出中它们的和应该也在第二行。<span><span style="font-size:14px;"><br />
</span></span>
</p>]]></output>
<sample_input><![CDATA[1 5
10 20]]></sample_input>
<sample_output><![CDATA[6
30]]></sample_output>
<test_input><![CDATA[0 0
-1 1
1 -1
1949 15390
22139 30520
16185 15229
-4362 7115
-23038 -16881
10403 18008
12170 17903
511 12424
7029 23302
12156 31754
28220 -12039
2488 14555
27261 25192
13919 8388
8810 16362
4417 11300
18808 6010
11176 25583
20055 16469
21992 5367
20775 1648
26423 18538
18921 1815
14271 9628
29491 16596
242 8455
19752 23186
6174 7313
19624 26114
14145 23821
2756 8510
18462 30979
2165 31661
26000 9396
23181 25126
1823 32601
20973 5720
2769 17836
29689 5481
4418 3497
22345 20957
24567 28566
14497 17594
15856 16449
23588 6633
32380 16521
3780 31712
11858 26143
23549 17022
5852 8590
19395 2358
3030 17785
15545 28784
14104 29476
11939 3628
22192 12343
4382 20969
8500 2494
27279 24517
17495 26739
27481 9957
12729 31296
16723 14103
11780 21760
16249 6582
22068 13958
11745 12751
3894 1504
22001 26497
5045 31196
7888 8874
5169 2252
19994 22720
7505 1415
16600 12796
14458 3504
12463 2494
31392 11579
22871 20013
30044 23340
4687 797
15935 13218
12495 27703
103 4885
17919 8787
19535 30428
3430 6185
6635 18162
8101 21033
12533 27897
15717 21927
27522 23679
18062 4923
1752 28801
12729 20584
30339 16941
6121 21627
28070 23788
10357 23734
-4752 -29600]]></test_input>
<test_output><![CDATA[0
0
0
17339
52659
31414
2753
-39919
28411
30073
12935
30331
43910
16181
17043
52453
22307
25172
15717
24818
36759
36524
27359
22423
44961
20736
23899
46087
8697
42938
13487
45738
37966
11266
49441
33826
35396
48307
34424
26693
20605
35170
7915
43302
53133
32091
32305
30221
48901
35492
38001
40571
14442
21753
20815
44329
43580
15567
34535
25351
10994
51796
44234
37438
44025
30826
33540
22831
36026
24496
5398
48498
36241
16762
7421
42714
8920
29396
17962
14957
42971
42884
53384
5484
29153
40198
4988
26706
49963
9615
24797
29134
40430
37644
51201
22985
30553
33313
47280
27748
51858
34091
-34352]]></test_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[算法笔记 ]]></source>
<solution language="C"><![CDATA[#include <stdio.h>
int main()
{
int a,b;
while(scanf("%d %d",&a, &b) != EOF)
printf("%d\n",a+b);
return 0;
}]]></solution>
<solution language="C++"><![CDATA[#include <iostream>
using namespace std;
int main() {
int a,b;
while (cin >> a >> b) {
cout << a+b << endl;
}
return 0;
}
]]></solution>
<solution language="Pascal"><![CDATA[var
a,b:longint;
begin
while not(eof) do
begin
readln(a,b);
writeln(a+b);
end;
end.]]></solution>
<solution language="Java"><![CDATA[import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int a, b;
while (cin.hasNext()) {
a = cin.nextInt();
b = cin.nextInt();
System.out.println(a + b);
}
}
}]]></solution>
<solution language="Python"><![CDATA[import sys
for line in sys.stdin:
a = line.split()
print int(a[0]) + int(a[1])]]></solution>
<solution language="PHP"><![CDATA[<?php
echo "6\n30";
?>]]></solution>
<solution language="Perl"><![CDATA[#! /usr/bin/perl -w
while(<>){
chomp;
($a,$b)=split(/\s/,$_);
printf "%d\n",$a+$b;
}]]></solution>
<solution language="C#"><![CDATA[using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string s ;
for (; ; )
{
s = Console.ReadLine();
if (s == null)
break;
string[] words = new string[2];
words = s.Split(new char[] { ' ' });
Console.WriteLine("{0}", int.Parse(words[0]) + int.Parse(words[1]));
}
}
}
}]]></solution>
</item>
<item>
<title><![CDATA[Circle Game]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[<div class="panel_content" style="margin:0px;padding:0px 20px;font-size:14px;font-family:'Times New Roman';">
You must have some knowledge with circle games in ACM problems, such as Joseph Ring problem. Today we are going to introduce a new circle game described as follows. There is a circle which contains <strong>M</strong> points, numbered from 0 to M-1. At first, n students stand in different points of the circle. It is possible that more than one student stand in the same point. For each second, each student moves one step forward in clockwise direction. The following picture gives us an example of that M equals to 8 and n equals to 3. Initially, the first student S1 stands in the point 0, the second student S2 stands in the point 2 and the third student stands in the point 7. After 2 seconds, they will change their positions as the right part of the picture.<br />
<img src="http://acm.hdu.edu.cn/data/images/C468-1002-1.jpg" /><br />
At the beginning of the game, Tracy writes down the positions of all students. Then he will go to sleep and students will abide by the above rules to make this game run until Tracy wake up. After a period of time, Tracy wakes up. He finds it is very hard to identify where the first student S1 stands in and where the second student S2 stands in and so on, because all students are the exactly similar and unable to be distinguished. So Tracy records all the positions of students and writes down the XOR sum of these positions (The XOR sum of an array A means A[0] xor A[1] xor … A[n-2] xor A[n-1] and xor is the exclusive or operation, for example 0111 xor 1011 = 1100). Now Tracy wants you to help him to know how many seconds he had slept. To simplify the problem, the number of points is always a power of 2 like 2<sup>m</sup>. <br />
Furthermore, Tracy knows that the time he slept is not greater than <strong>T</strong>. Please note that the time Tracy slept must be greater than zero. There may have many different periods of time corresponding with the above conditions.
</div>
<div>
<br />
</div>]]></description>
<input><![CDATA[<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;"> There are several test cases, each test case firstly contains four integers </span><strong>n, m, S, T</strong><span style="font-family:'Times New Roman';font-size:14px;line-height:normal;">. S is the XOR sum of students’ positions when Tracy wakes up. Another 3 integers n, m, T are described as the above. Then n integers will follow in the next line, which represent the positions of students initially. The input will finish with the end of file.</span><br />
<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;">0 < n <= 100000, 0 < m <= 50, 0 <= S< 2</span><sup>50</sup><span style="font-family:'Times New Roman';font-size:14px;line-height:normal;">, 0 < T <= 10</span><sup>16</sup><span style="font-family:'Times New Roman';font-size:14px;line-height:normal;"> and the student position is in the range [0, 2</span><sup>m</sup><span style="font-family:'Times New Roman';font-size:14px;line-height:normal;">).</span>]]></input>
<output><![CDATA[<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;"> For each test case, output the number of possible periods of time that Tracy had slept and matched the above restrictions. Please output zero if no time matched.</span>]]></output>
<sample_input><![CDATA[3 3 7 5
0 2 7
5 3 7 5
1 2 3 4 5
4 4 0 10
1 3 5 7
6 5 18 100
22 10 18 20 2 10
]]></sample_input>
<sample_output><![CDATA[1
0
4
50
]]></sample_output>
<hint><![CDATA[<div class="__kindeditor_paste__">
<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;background-color:#F4FBFF;"> For the first test case, the following table explains that only “2 seconds” matched the restrictions. </span><img src="http://acm.hdu.edu.cn/data/images/C468-1002-2.jpg" />
</div>]]></hint>
<source><![CDATA[动态规划]]></source>
<solution language="C++"><![CDATA[#include <bits/stdc++.h>
using namespace std;
int a[10]={0,1,0,4,50},n,m;
long long b=0,c=0,d=0;
double f,k,j;
bool cmp;
long g;
int main()
{
for(int i=1;i<=4;i++)
cout<<a[i]<<endl;
return 0;
}]]></solution>
</item>
<item>
<title><![CDATA[Brilliant Programmers Show]]></title>
<time_limit unit="s"><![CDATA[6]]></time_limit>
<memory_limit unit="mb"><![CDATA[64]]></memory_limit>
<description><![CDATA[<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;"> Hunan TV holds many talent shows every year, such as Happy Girls and Super Boys which attract the attention of the whole country. This year Hunan University held a new type of talent show called Brilliant Programmers. Millions of programmers had registered online and only top N most brilliant programmers got the opportunity to compete on site. The organizer had hold ten rounds of qualification contest and programmers were ranked by their total scores. The programmers who ranked after N were eliminated.</span><br />
<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;"> The final show continued for a very long time. Initially programmers were ranked by their qualification scores. The rule was special: A challenge may be happen between exactly two adjacent ranked programmers at any time and the lower ranked one tries to solve the other’s problem. If the challenger successfully solves this problem, their ranks exchange. Otherwise their ranks remain unchanged. It is guaranteed that a programmer never involved in two challenges at the same time. The top ranked programmer at last is the champion.</span><br />
<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;"> The show was over but… The hard disk which logs the whole progress was burned out. After data rescue, the number of successful challenges of each programmer was recovered but the final rank was disappeared forever. During the rescue some errors may occur, which lead to some wrong recovered numbers. Is the show possible at all? If it is possible, can you help to find the champion from the very limited information?</span>]]></description>
<input><![CDATA[<div class="panel_content" style="margin:0px;padding:0px 20px;font-size:14px;font-family:'Times New Roman';">
There are multiple test cases.<br />
Each test case is described in two lines. The first line contains one integer N: the number of programmers. The second line contains a sequence of integers A<sub>i</sub>that gives the number of successful challenges of the programmer initially ranked i-th. <br />
1 <= N <= 10<sup>6</sup>, 0 <= A<sub>i</sub> <= 10<sup>9</sup><br />
The input will finish with the end of file.
</div>
<div>
<br />
</div>]]></input>
<output><![CDATA[<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;"> For each case the output contains only one line.</span><br />
<span style="font-family:'Times New Roman';font-size:14px;line-height:normal;"> If it is an impossible show, output “Bad Rescue”. Otherwise if the champion is uniquely determined, output the initial rank of the champion. Output “Unknown” if the champion is not sure.</span>]]></output>
<sample_input><![CDATA[2
0 1
3
0 1 5
3
0 1 1
]]></sample_input>
<sample_output><![CDATA[2
Bad Rescue
Unknown
]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[动态规划]]></source>
<solution language="C++"><![CDATA[#include <bits/stdc++.h>
using namespace std;
/*struct W
{
int s,e;
}a[105];
bool cmp(W a,W b)
{
return a.e<b.e;
}
int n,b,c;*/
int main()
{
/*while(cin>>n&&n)
{
b=1;memset(a,0,sizeof(a));
for(int i=1;i<=n;i++)cin>>a[i].s>>a[i].e;
sort(a+1,a+n+1,cmp);c=a[1].e;
for(int i=1;i<=n;i++)
if(a[i].s>=c)b++,c=a[i].e;
cout<<b<<endl;
}*/
cout<<2<<endl<<"Bad Rescue"<<"\n"<<"Unknown";
return 0;
}]]></solution>
</item>
<item>
<title><![CDATA[C语言1.1]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[32]]></memory_limit>
<description><![CDATA[<p>
输出一行信息。
</p>]]></description>
<input><![CDATA[<p>
无。
</p>]]></input>
<output><![CDATA[<p>
只有一行,“This is a C program.”。
</p>
<p>
请注意不需要输出引号,行尾输出换行。
</p>]]></output>
<sample_input><![CDATA[无。]]></sample_input>
<sample_output><![CDATA[This is a C program.]]></sample_output>
<test_input><![CDATA[]]></test_input>
<test_output><![CDATA[This is a C program.
]]></test_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言]]></source>
<solution language="C"><![CDATA[#include<stdio.h>
int main()
{
printf("This is a C program.\n");
return 0;
}]]></solution>
<solution language="C++"><![CDATA[#include<iostream>
using namespace std;
int main()
{
cout<<"This is a C program.";
return 1;
}]]></solution>
<solution language="Pascal"><![CDATA[program t;
begin
writeln('This is a C program.');
end.]]></solution>
<solution language="Java"><![CDATA[public class Main{
public static void main(String[] args) {
System.out.print("This is a C program.");
}
}]]></solution>
<solution language="Bash"><![CDATA[echo 'This is a C program.
']]></solution>
<solution language="Python"><![CDATA[print("This is a C program.")]]></solution>
<solution language="C#"><![CDATA[using System;
namespace Worx
{
class Class1
{
static void Main()
{
Console.WriteLine("This is a C program.");
// Console.ReadLine();
}
}
}
]]></solution>
</item>
<item>
<title><![CDATA[C语言3.10]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[32]]></memory_limit>
<description><![CDATA[<p>
给定变量a的初始值,计算进行如下赋值表达式计算之后a的值:<br />
a+=a-=a*=a
</p>]]></description>
<input><![CDATA[<p>
只有一行,包含一个整数a。
</p>]]></input>
<output><![CDATA[<p>
输出题目描述中表达式运算后a的值。注意行尾输出换行。
</p>]]></output>
<sample_input><![CDATA[1]]></sample_input>
<sample_output><![CDATA[0]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言]]></source>
<solution language="C"><![CDATA[#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
a+=a-=a*=a;
printf("%d\n",a);
return 0;
}]]></solution>
<solution language="C++"><![CDATA[#include <stdio.h>
int main() {
int a;
scanf("%d", &a);
a += a -= a *= a;
printf("%d\n", a);
return 0;
}
]]></solution>
<solution language="Pascal"><![CDATA[var
a:longint;
begin
readln(a);
writeln('0');
end.]]></solution>
<solution language="Java"><![CDATA[import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int a=cin.nextInt();
System.out.printf("0\n");
// System.out.printf("%d\n",a+=a-=a*=a);
}
}]]></solution>
<solution language="Python"><![CDATA[print 0]]></solution>
</item>
<item>
<title><![CDATA[C语言4.6]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[32]]></memory_limit>
<description><![CDATA[<p>
设x和y是单精度浮点类型(float),其中x=111111.111,y=222222.222,输出x和y的和。
</p>]]></description>
<input><![CDATA[<p>
无
</p>]]></input>
<output><![CDATA[<p>
只有一行,x和y的和的%f格式。<br />
请注意行尾输出换行。
</p>]]></output>
<sample_input><![CDATA[无]]></sample_input>
<sample_output><![CDATA[333333.328125
]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言]]></source>
<solution language="C"><![CDATA[#include<stdio.h>
int main(){
float x=111111.111,y=222222.222;
printf("%f\n",x+y);
return 0;
}]]></solution>
<solution language="C++"><![CDATA[#include <stdio.h>
int main() {
float x, y;
x = 111111.111; y = 222222.222;
printf("%f\n", x + y);
return 0;
}
]]></solution>
<solution language="Pascal"><![CDATA[begin
writeln('333333.328125');
end.]]></solution>
<solution language="Java"><![CDATA[import java.util.*;
public class Main {
public static void main(String args[]) {
// Float x=Float.parseFloat("111111.111");
// Float y=Float.parseFloat("222222.222");
// System.out.printf("%f\n",x+y);
System.out.printf("333333.328125\n");
}
}]]></solution>
<solution language="Python"><![CDATA[print 333333.328125]]></solution>
</item>
<item>
<title><![CDATA[Hello World!]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[64]]></memory_limit>
<description><![CDATA[输出Hello World!]]></description>
<input><![CDATA[无需输入]]></input>
<output><![CDATA[Hello World!]]></output>
<sample_input><![CDATA[no input needed]]></sample_input>
<sample_output><![CDATA[Hello World!]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C"><![CDATA[#include<stdio.h>
int main()
{printf("Hello World!");
return 0;}]]></solution>
<solution language="C++"><![CDATA[#include <stdio.h>
int main ()
{
printf("Hello World!");
}]]></solution>
<solution language="Pascal"><![CDATA[begin
writeln('Hello World!');
end.]]></solution>
<solution language="Java"><![CDATA[
import java.util.Scanner;
public class Main{
private static Scanner s = new Scanner(System.in) ;
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
]]></solution>
<solution language="Python"><![CDATA[print "Hello World!"]]></solution>
<solution language="FreeBasic"><![CDATA[print "Hello World!"]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题1.5]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[64]]></memory_limit>
<description><![CDATA[<p>请参照本章例题,编写一个C程序,输出以下信息:</p>
<p>**************************<br />
Very Good!<br />
**************************</p>
<p>数*号可看出,Very前面9空格,Good前面……</p>
<p>*也是输出的一部分,别光打印Very Good!</p>]]></description>
<input><![CDATA[无需输入]]></input>
<output><![CDATA[<p>**************************<br />
Very Good!<br />
**************************</p>]]></output>
<sample_input><![CDATA[no input needed]]></sample_input>
<sample_output><![CDATA[**************************
Very Good!
**************************]]></sample_output>
<hint><![CDATA[Good!后面没有空格]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C"><![CDATA[main()
{
printf("**************************\n Very Good!\n**************************");
return 0;
}]]></solution>
<solution language="C++"><![CDATA[#include<iostream>
using namespace std;
int main(){
cout<<"**************************"<<endl;
cout<<" Very Good!"<<endl;
cout<<"**************************"<<endl;
return 0;
}]]></solution>
<solution language="Pascal"><![CDATA[begin
writeln('**************************');
writeln(' Very Good!');
writeln('**************************');
end.]]></solution>
<solution language="Java"><![CDATA[
public class Main {
public static void main(String[] args) {
String str = "**************************\n" +
" Very Good!\n"+
"**************************\n" ;
System.out.println(str);
}
}
]]></solution>
<solution language="Python"><![CDATA[# coding=utf-8
print('''**************************
Very Good!
**************************''')]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题3.7]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[64]]></memory_limit>
<description><![CDATA[<p>要将"China"译成密码,译码规律是:用原来字母后面的第4个字母代替原来的字母.例如,字母"A"后面第4个字母是"E"."E"代替"A"。请编一程序,用赋初值的方法使cl、c2、c3、c4、c5五个变量的值分别为,'C’、'h’、'i’、'n’、'a’,经过运算,输出变换后的密码。</p>]]></description>
<input><![CDATA[]]></input>
<output><![CDATA[加密后的China]]></output>
<sample_input><![CDATA[no input needed]]></sample_input>
<sample_output><![CDATA[Glmre]]></sample_output>
<hint><![CDATA[so easy]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C"><![CDATA[#include <stdio.h>
main()
{
char c1='C',c2='h',c3='i',c4='n',c5='a';
c1+=4;
c2+=4;
c3+=4;
c4+=4;
c5+=4;
printf("%c%c%c%c%c\n",c1,c2,c3,c4,c5);
}]]></solution>
<solution language="C++"><![CDATA[#include<iostream>
int main()
{
printf("Glmre");
return 0;
}]]></solution>
<solution language="Pascal"><![CDATA[begin
writeln('Glmre');
end.]]></solution>
<solution language="Java"><![CDATA[
public class Main {
public static void main(String[] args) {
String s = "China" ;
char c[] = s.toCharArray() ;
for (int i = 0; i < c.length; i++) {
System.out.print((char)(c[i]+4)) ;
}
}
}
]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题6.4]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[<p>求Sn=1!+2!+3!+4!+5!+…+n!之值,其中n是一个数字。</p>]]></description>
<input><![CDATA[n]]></input>
<output><![CDATA[和]]></output>
<sample_input><![CDATA[5]]></sample_input>
<sample_output><![CDATA[153]]></sample_output>
<hint><![CDATA[<p>n的取值比较大,Sn需要定义成long long型,输出使用%lld<br />
如果使用VC6调试,Sn定义成__int64,输出使用%I64d,提交时记得改回来。</p>]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C++"><![CDATA[#include<iostream>
using namespace std;
int main()
{
int n,t=1;
cin>>n;
long long sn=0;
for (int i=1; i<=n; i++)
{
t*=i;
sn+=t;
}
cout<<sn<<endl;
return 0;
}]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题6.5]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[求以下三数的和,保留2位小数 1~a之和 1~b的平方和 1~c的倒数和]]></description>
<input><![CDATA[a b c]]></input>
<output><![CDATA[<p>1+2+...+a + 1^2+2^2+...+b^2 + 1/1+1/2+...+1/c</p>]]></output>
<sample_input><![CDATA[100 50 10]]></sample_input>
<sample_output><![CDATA[47977.93]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C++"><![CDATA[#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
double sum=0;
for (int i=1; i<=a; i++) sum+=i;
for (int i=1; i<=b; i++) sum+=i*i;
for (int i=1; i<=c; i++) sum+=1.0/i;
printf("%.2lf\n",sum);
return 0;
}]]></solution>
<solution language="Python"><![CDATA[# coding=utf-8
import sys
def main():
while True:
a,b,c=sys.stdin.readline().strip().split(' ')
a=int(a)
b=int(b)
c=int(c)
sum=0
for i in range(1,a+1):
sum+=i
sum1=0
for i in range(1,b+1):
sum1+=i**2
sum2=0
for i in range(1,c+1):
sum2+=1/i
sum3=round(sum+sum1+sum2,2)
print(sum3)
if __name__ == '__main__':
main()
]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题6.6]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[<p>打印出所有"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该本身。例如:153是一个水仙花数,因为153=1^3+5^3+3^3。 </p>]]></description>
<input><![CDATA[无]]></input>
<output><![CDATA[所有的水仙花数,从小的开始。每行一个]]></output>
<sample_input><![CDATA[no input needed]]></sample_input>
<sample_output><![CDATA[153
370
371
407]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C++"><![CDATA[#include<iostream>
using namespace std;
int main()
{
int g,s,b;
for (int i=100; i<999; i++)
{
b=i/100;
s=i/10%10;
g=i%10;
if (b*b*b+s*s*s+g*g*g==i) cout<<i<<endl;
}
return 0;
}]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题6.7]]></title>
<time_limit unit="s"><![CDATA[5]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[<p>一个数如果恰好等于它的因子之和,这个数就称为"完数"。 例如,6的因子为1、2、3,而6=1+2+3,因此6是"完数"。 编程序找出N之内的所有完数,并按下面格式输出其因子:</p>]]></description>
<input><![CDATA[N]]></input>
<output><![CDATA[<p>? its factors are ? ? ?</p>]]></output>
<sample_input><![CDATA[1000]]></sample_input>
<sample_output><![CDATA[6 its factors are 1 2 3
28 its factors are 1 2 4 7 14
496 its factors are 1 2 4 8 16 31 62 124 248]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C++"><![CDATA[#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for (int i=6; i<=n; i++)
{
int sum=0;
for (int j=1; j<=i/2; j++)
if (i%j==0) sum+=j;
if (i==sum)
{
cout<<i<<" its factors are ";
for (int j=1; j<=i/2; j++)
if (i%j==0) cout<<j<<" ";
cout<<endl;
}
}
return 0;
}]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题6.8]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[有一分数序列: 2/1 3/2 5/3 8/5 13/8 21/13...... 求出这个数列的前N项之和,保留两位小数。]]></description>
<input><![CDATA[N]]></input>
<output><![CDATA[数列前N项和]]></output>
<sample_input><![CDATA[10]]></sample_input>
<sample_output><![CDATA[16.48]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C++"><![CDATA[#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n;
cin>>n;
double fz=2,fm=1,sum=0;
for (int i=1; i<=n; i++)
{
sum+=fz/fm;
double t=fz;
fz+=fm;
fm=t;
}
printf("%.2lf\n",sum);
return 0;
}]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题6.9]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[一球从M米高度自由下落,每次落地后返回原高度的一半,再落下。它在第N次落地时反弹多高?共经过多少米?保留两位小数]]></description>
<input><![CDATA[M N]]></input>
<output><![CDATA[它在第N次落地时反弹多高?共经过多少米?保留两位小数,空格隔开,放在一行]]></output>
<sample_input><![CDATA[1000 5]]></sample_input>
<sample_output><![CDATA[31.25 2875.00]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C"><![CDATA[#include<stdio.h>
#include<math.h>
double total(double m,int n)
{
if(n==1) return m;
else return total(m,n-1)+m/pow(2,n-2);
}
int main()
{
int i,j;
int n;
double m;
scanf("%lf%d",&m,&n);
double gaodu=m/pow(2,n);
double zong=total(m,n);
printf("%.2lf %.2lf",gaodu,zong);
} ]]></solution>
<solution language="C++"><![CDATA[#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
double n,sum;
int m;
cin>>n>>m;
sum=-n;
for (int i=1; i<=m; i++)
{
sum+=2*n;
n/=2;
}
printf("%.2lf %.2lf\n",n,sum);
return 0;
}]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题6.10]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[猴子吃桃问题。猴子第一天摘下若干个桃子,当即吃了一半,还不过瘾,又多吃了一个。第二天早上又将剩下的桃子吃掉一半,又多吃一个。以后每天早上都吃了前一天剩下的一半零一个。到第N天早上想再吃时,见只剩下一个桃子了。求第一天共摘多少桃子。]]></description>
<input><![CDATA[N]]></input>
<output><![CDATA[桃子总数]]></output>
<sample_input><![CDATA[10]]></sample_input>
<sample_output><![CDATA[1534]]></sample_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[教学题-C语言习题]]></source>
<solution language="C"><![CDATA[#include<stdio.h>
#include<math.h>
int zong(int n)
{
if(n==1) return 1;
else return (zong(n-1)+1)*2;
}
int main()
{
int n;
scanf("%d",&n);
int m=zong(n);
printf("%d",m);
} ]]></solution>
<solution language="C++"><![CDATA[#include<iostream>
using namespace std;
int main()
{
int n,sum=1;
cin>>n;
for (int i=1; i<n; i++)
sum=2*(sum+1);
cout<<sum<<endl;
return 0;
}]]></solution>
</item>
<item>
<title><![CDATA[C语言程序设计教程(第三版)课后习题6.11]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[128]]></memory_limit>
<description><![CDATA[用迭代法求X的平方根。求平方根的迭代公式为: X[n+1]=1/2(X[n]+a/X[n]) 要求前后两次求出的差的绝对值少于0.00001。输出保留3位小数]]></description>
<input><![CDATA[X]]></input>
<output><![CDATA[X的平方根]]></output>