LCM Challenge(数论)

来源:互联网 发布:java之gui编程 三 编辑:程序博客网 时间:2024/06/10 18:19


Link:http://acdream.info/problem?pid=1077


LCM Challenge

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)
Submit Statistic Next Problem

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


AC  code:

#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#include<cmath>#include<queue>#include<vector>#include<map>#define LL long long#define MAXN 1000010using namespace std;int main(){    LL ans,n;while(cin>>n){if(n<=2){ans=n;}else if(n%2){ans=n*(n-1)*(n-2);}else{if(n%3){ans=n*(n-1)*(n-3);}else{ans=(n-1)*(n-2)*(n-3);}}cout<<ans<<endl;}return 0; } 



0 0
原创粉丝点击