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
规律题~1,2特殊枚举~
AC代码:
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
int main()
{
LL N;
LL ans;
scanf("%lld",&N);
if(N == 1) printf("1\n");
else if(N == 2) printf("2\n");
else{
if(N % 2 == 0 && N % 3 == 0)
ans = (N - 1) * (N - 2) * (N - 3);
else if(N % 2 == 0)
ans = N * (N - 1) * (N - 3);
else ans = N * (N - 1) * (N - 2);
printf("%lld\n",ans);
}
return 0;
}