NOI题库的一些题

# 1 1481:Maximum sum

Given a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below:

$d(A) = max\{ \sum_{i=s1}^{t1} ai + \sum_{i=s2}^{t2}aj , 1 \le s1 \le t1 \lt s2 \le t2 \le n \}$

【描述】

【输入】

【输出】

# 3 1551:Sumsets

Given S, a set of integers, find the largest d such that a + b + c = d where a, b, c, and d are distinct elements of S.

# 4 1350:Euclid's Game

Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the lesser of the two numbers from the greater of the two numbers, provided that the resulting number must be nonnegative. Then Ollie, the second player, does the same with the two resulting numbers, then Stan, etc., alternately, until one player is able to subtract a multiple of the lesser number from the greater to reach 0, and thereby wins. For example, the players may start with (25,7):
25 7
11 7
4 7
4 3
1 3
1 0
an Stan wins.

# 6 1538:Gopher II

The gopher family, having averted the canine threat, must face a new predator.
The are n gophers and m gopher holes, each at distinct (x, y) coordinates. A hawk arrives and if a gopher does not reach a hole in s seconds it is vulnerable to being eaten. A hole can save at most one gopher. All the gophers run at the same velocity v. The gopher family needs an escape strategy that minimizes the number of vulnerable gophers.

# 7 1249:Humble Numbers

A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.
Write a program to find and print the nth element in this sequence.
【output】
For each test case, print one line saying "The nth humble number is number.". Depending on the value of n, the correct suffix "st", "nd", "rd", or "th" for the ordinal number nth has to be used like it is shown in the sample output.

# 8 1413:Mondriaan's Dream

Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his 'toilet series' (where he had to use his toilet paper to draw on, for all of his paper was filled with squares and rectangles), he dreamt of filling a large rectangle with small rectangles of width 2 and height 1 in varying ways. Expert as he was in this material, he saw at a glance that he'll need a computer to calculate the number of ways to fill the large rectangle whose dimensions were integer values, as well. Help him, so that his dream won't turn into a nightmare!

n和m均为奇数的话，矩形面积就是奇数，可知是不可能完全覆盖的。

1. 第i行的第j列为1，第i-1行的第j列为1，这样的话，说明第i行的第j列一定不是竖放而是横放否则会与第i-1行的第j列冲突
所以马上紧接着判断第i行第j+1列，如果是1，那么满足横放的规则，同时也要第i-1行第j+1列也要为1，否则的话这个格子没办法填充
成立后向左移动两格
不满足上述条件的，就是两个不兼容或者不合法的状态
2. 第i行第j列为1，第i-1行第j列为0，那么说明第i行第j列应该竖放并填充第i-1行第j列，成立后向左移动一格
3. 第i行第j列为0，说明不放方块，那么第i-1行第j列必须为1，否则没法填充这个格子。若第i-1行第j列也为0，不兼容不合法

# 9 1455:An Easy Problem

As we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form.
Given a positive integer I, you task is to find out an integer J, which is the minimum integer greater than I, and the number of '1's in whose binary form is the same as that in the binary form of I.
For example, if "78" is given, we can write out its binary form, "1001110". This binary form has 4 '1's. The minimum integer, which is greater than "1001110" and also contains 4 '1's, is "1010011", i.e. "83", so you should output "83".

0 -2 -7 0
9 2 -6 2
-4 1 -4 1
-1 8 0 -2

9 2
-4 1
-1 8