acdream1077

maksyuki 发表于 oj 分类,标签:
0

Problem Description

Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.

But I also don't want to use many numbers, so I'll choose three positive integers (they don't have to be distinct) which are not greater than n. Can you help me to find the maximum possible least common multiple of these three integers?

Input

The first line contains an integer n (1 ≤ n ≤ 10^6) — the n mentioned in the statement.

Output

Print a single integer — the maximum possible LCM of three not necessarily distinct positive integers that are not greater than n.

Sample Input

9

Sample Output

504

Source

WJMZBMR

Manager

admin

 

题目类型:LCM

算法分析:题目要求的是任意3个大于等于1小于等于n的数的最小公倍数的最大值。由于有相邻两个自然数a、a+1的最大公约数是1,即意味着相邻两个数的最小公倍数是a *(a+1)。如果n是奇数,则可易知n*(n-1)*(n-2)就是最大的LCM。如果n是偶数,则判断n是否是3的倍数。如果是,则(n-1)*(n-2)*(n-3)就是结果,反之,结果是n*(n-1)*(n-3)。对于后面的结论,进行一个简单的说明:首先(n-1)*(n-2)*(n-3)要比(n-1)*n*(n-3)小,但是如果3|n,则n和n-3的最小公倍数就不是1了。会导致结果变小,所以此时不应该选择这种情况