版权声明:写的不对不好的地方希望大家能“狠狠地”指出来:) https://blog.csdn.net/qq_37006625/article/details/85272256
1.蓝桥杯 算法训练 最大最小公倍数
问题描述
已知一个正整数N,问从1~N中任选出三个数,他们的最小公倍数最大可以为多少。
输入格式
输入一个正整数N。
输出格式
输出一个整数,表示你找到的最小公倍数。
样例输入
9
样例输出
504
数据规模与约定
1 <= N <= 106。
代码
/*
已知一个正整数N,问从1~N中任选出三个数,他们的最小公倍数最大可以为多少。
*/
#include<iostream>
using namespace std;
void Max_times(long long n)
{
long long ans;
if(n <= 2) ans = n;
else{
if(n%2!=0){
ans = (n-2)*(n-1)*n;
}
else{
if(n%3==0){
ans = (n-3)*(n-2)*(n-1);
}
else{
ans = (n-3)*(n-1)*n;
}
}
}
cout << ans << endl;
}
int main()
{
long long n;
while(cin >> n){
Max_times(n);
}
return 0;
}