haihongyuan.com

# 奥林匹克信息学选题及解答

Addtion of numbers

Time Limit: 2 seconds

Eric is currently studying in Primary two. He was asked to do n ( 1 n

20 ) addition problems,

31which is to sum up two integers, a and b ( 1 a, b < 2 ). He has to hand this in tomorrow.

However, he is a very lazy student. He wants to play lego instead of doing this homework. You are Eric's elder brother and he ask you to help him. As both of you are lazy guys, you decide to write a program to complete this task rather than calculating those by hand. Input

The input contains n + 1 lines of input. The first line of the input is the number n. The second line to the n + 1th line contains two numbers a and b at each line.

Output

The output file contains n lines, which are the sum of a and b. The i-th line of output is the sum of the two integers in the i+1-th line of input.

Sample Input

5

1 1

2 9

3 6

4 19

5 200

Sample Output

2

11

9

23

205

1<=b,c<=10^9

The `if' statement

Time Limit: 1 second

Memory Limit: 1 MB

Write a program to read in an integer n ( 0 < n < 2 ) . If n is an odd number which lies between 50 and 100 (excluding 50 and 100), the program should output n. Otherwise if n is a multiple of 6 or 7, the program should output 2n. If n does not statisfy the above conditions, the program should output 3n. 60

Input

The input file contains an integer n.

Output

The output contains 1 line, which is the result of the above description.

Sample Input

24

Sample Output

48

Alphabet Sorting

Time Limit: 1 second

Memory Limit: 1 MB

Allen is currently studying the 26 letters. Please write a program to help him to identify the 10th letter, after sorting in ascending order, in the input.

Input

The inpue file contains n+1 lines. The first line contains an integer n ( 11 n

26 ). Each of the following n lines contain a lower case letter.

Output

The output contains the 10th letter after sorting in ascending order.

Sample Input

11

a

c

b

e

f

d

g

z

h

i

x

Sample Output

x

Taking Square Roots

Time Limit: 1 second

Given a list of integers, output the result after taking the square roots rounded up to 3 decimal places. The first line of input consists of one non-negative integer N, which is smaller than 21, which indicates the number of test cases. The following N lines contain an integer in each line, which lies between -40000 and 40000. Output its square root up to 3 decimal places. If the square root is not real, you should display `i' after the number. Sample Input

2

4

-4

Sample Output

2.000

2.000i

Output Your Message

Time Limit: 1 second

Memory Limit: 1 MB

Given a name in the input, please output the name with an additional string `, you are fired.' If the input is either `Marcus', `Patrick' or `Sherman' (these theee names are sorted in lexicographical order), please output his name and ` is extremely clever.'. It is guranteed that the string in the input contains at most 255 characters and the characters are all printable ASCII characters.

Sample Input 1

Simon

Sample Output 1

Simon, you are fired.

Sample Input 2

Patrick

Sample Output 2

Patrick is extremely clever.

Sample Input 3

Sherman

Sample Output 3 Sherman is extremely clever.

Sherman's Website

Time Limit: 3 seconds

Sherman is an experienced website designer. He built a famous website, comfield, which attracts millions of visitors to browse his website per day. This website provides a wide variety of services, games, articles and even online judge for the users. It is extremely popular and nearly every Hong Kong people know his webiste. Marcus and Patrick are his fans and they post a lot of threads in his forum. He currently has 2147483647 threads in his forum! Sherman wants to post some statistics of his website to prove that his website is really popular. He wants to do some statistical analysis. From his server software, he knows that the number of visitors of his website per hour. However, he does not know much about statistics as he is too young to learn it. As a friend of Sherman, you have the responsibility to help him.

Given a specified time period, and the number of visitors per hour, write a program which tells him the mean and median of these statistics.

Input

The input file consists of N + 1 lines. The first line contains an integer N ( 1 N

100000 ), which is the number of hours provided in the statistics. The 2nd to the N + 1th line are the number of visitors per hour, which are non-negative integers less than 21475.

Output

The output file should contain 3 lines. The first line contains the time period, in days, in this statistical report. One day is added if the exceeding hours cannot form a new day. The second line of output is the mean (correct to three decimal places) and the third line is the median (correct to the nearest integer). You should follow the output format as shown in the sample output.

Sample Input

5

1

2

3

4

5

Sample Output

1 day(s)

Mean: 3.000

Median: 3

1 3 3 4 5 10

3 4 5

1981 2000

5

K N L

8 10 2

10 10 16

1000

A

a+(b+c) a+b+c

(a*b)+c/d a*b+c/d

a+b/(c-d) a+b/(c-d)

【题目描述】

STEP1：87+78 = 165 STEP2：165+561 = 726

STEP3：726+627 = 1353 STEP4：1353+3531 = 4884

【输入格式】

【输出格式】

【输入样例】

87

【输出样例】

4

1．奖学金

(scholar.pas/c/cpp)

【问题描述】

7 279

5 279

5 279

7 279

【输入】

【输出】

【输入输出样例1】

【输入输出样例2】

【限制】

50%的数据满足：各学生的总成绩各不相同

100%的数据满足：6<=n<=300

【问题】n（3≤n≤1000）只猴子选大王，选举办法如下：从头到尾１，２，３报数，凡报３的退出，余下的从尾到头１，２，３报数，凡报３的退出．．．如此类推，当剩下两只猴子时，取这时报１的为王，若想当猴王，请问当初应占据什么位置？

【输入样例】

7

【输出样例】

2 应该是6

【问题描述】

【输入】

【输出】

【输入输出样例1】

3

1 0 2 3

0 2 3 3

2 1 3 3

2 2

3

【输入输出样例说明】

【输入输出样例2】

3

1 0 2 3

0 2 3 3

2 1 3 3

4 5

-1

【输入输出样例说明】

【数据范围】

(count.cpp/c/pas)

【问题描述】

【输入】

【输出】

【输入输出样例】

count.in count.out

11 1 4

【数据说明】

【问题描述】 某校大门外长度为L的马路上有一排树，每两棵相邻的树之间的间隔都是 1米 。我们可以把马路看成一个数轴，马路的一端在数轴0的位置，另一端在L的位置；数轴上的每个整数点，即0，1，2，??，L，都种有一棵树。由于马路上有一些区域要用来建地铁。这些区域用它们在数轴上的起始点和终止点表示。已知任一区域的起始点和终止点的坐标都是整数，区域之间可能有重合的部分。现在要把这些区域中的树（包括区域端点处的两棵树）移走。你的任务是计算将这些树都移走后，马路上还有多少棵树。

【输入文件】 输入文件tree.in的第一行有两个整数L（1 <= L <= 10000）和 M（1 <= M <= 100），L代表马路的长度，M代表区域的数目，L和M之间用一个空格隔开。接下来的M行每行包含两个不同的整数，用一个空格隔开，表示一个区域的起始点和终止点的坐标。

【输出文件】 输出文件tree.out包括一行，这一行只包含一个整数，表示马路上剩余的树的数目。

【样例输入】

500 3

150 300

100 200

470 471

【样例输出】 298

【数据规模】 对于20%的数据，区域之间没有重合的部分；对于其它的数据，区域之间有重合的情况。

All rights reserved Powered by 海文库
copyright ©right 2010-2011。