SRM 440 1000分的题 -------------------- 有点难,大家做做看。

1 view
Skip to first unread message

higer

unread,
May 18, 2009, 8:09:59 AM5/18/09
to 编程爱好者天地
A square-free number is an integer that is not divisible by the square
of any integer except 1. A set containing only square-free numbers is
called a square-free set. The product of such a set is the product of
all its elements. If the product of a square-free set is a square-
free number itself, that set is called a perfect set.

You are given two ints N and K. Determine the number of perfect
square-free sets that contain between 1 and K elements, inclusive,
where each element is between 2 and N, inclusive. Return this number
modulo 1,000,000,007.

DEFINITION
Class:SquareFreeSets
Method:countPerfect
Parameters:int, int
Returns:int
Method signature:int countPerfect(int N, int K)


CONSTRAINTS
-N will be between 2 and 500, inclusive.
-K will be between 1 and 500, inclusive.


EXAMPLES

0)
5
1

Returns: 3

The possible sets are: {2}, {3}, {5}.

1)
5
2

Returns: 6

Here, {2,3}, {2,5} and {3,5} are also possible.


2)
5
3

Returns: 7

The set {2,3,5} is added to the previous ones.


3)
6
3

Returns: 9

Here, the sets are: {2}, {3}, {5}, {6}, {2,3}, {2,5}, {3,5}, {5,6},
{2,3,5}.


4)
28
41

Returns: 1599
Reply all
Reply to author
Forward
0 new messages