cf146div2_c. LCM Challenge

来源:互联网 发布:王者荣耀引流源码 编辑:程序博客网 时间:2024/06/05 16:03
C. LCM Challenge
timelimit per test
2 seconds
memorylimit per test
256 megabytes
input
standard input
output
standard output

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

But I also don't want to use many numbers, so I'll choose threepositive integers (they don't have to be distinct) which are notgreater thann.Can you help me to find the maximum possible least common multipleof these three integers?

Input

The first line contains an integer n (1 ≤ n ≤ 106)— the n mentionedin the statement.

Output

Print a single integer — the maximum possible LCM of three notnecessarily distinct positive integers that are not greaterthan n.

Sample test(s)
input
9
output
504
input
7
output
210
Note

The least common multiple of some positive integers is the leastpositive integer which is multiple for each of them.

The result may become very large, 32-bit integer won't be enough.So using 64-bit integers is recommended.

For the last example, we can chosenumbers 765 andthe LCM of them is 7·6·5 = 210.It is the maximum value we can get.

题意:求一个数n比他《=的三个数的最小公倍数中最大。

找规律。列几个数观察下。还有1,2这个单独输出

 

#include

#include

#include

using namespace std;


int main()

{

    __int64n;

   while(scanf("%I64d",&n)!=EOF)

    {

       if(n==1)printf("1\n");

       else if(n==2)printf("2\n");

       else if(n%2==1)

       {

          printf("%I64d\n",n*(n-1)*(n-2));

       }

       else if(n%3==0)

       {

          printf("%I64d\n",(n-1)*(n-2)*(n-3));

       }

       else

       {

          printf("%I64d\n",(n)*(n-1)*(n-3));

       }

    }

    return0;

}


原创粉丝点击