几天以前,我学习了最小公倍数。玩得挺久了,想换换口味。
我不想用太多的数字,我想从1到n中选三个数字(可以相同)。使得他们的最小公倍数最大。
Input
单组测试数据。 第一行有一个整数n (1≤n≤1,000,000)。
Output
输出一个整数表示选三个数字的最大的最小公倍数。
Input示例
9 7
Output示例
504 210
响邻两个自然数互质,相邻两个奇数肯定互质
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
// freopen("in.txt", "r", stdin);
int n;
while(scanf("%d", &n) == 1){
if(n == 1){
puts("1");
}
else if(n == 2){
puts("2");
}
else{
if(n % 2 != 0){
printf("%I64d\n", (ll)n*(n-1)*(n-2));
}
else{
if(n % 3 == 0)
printf("%I64d\n", (ll)(n-1)*(n-2)*(n-3));
else
printf("%I64d\n", (ll)n * (n-1) * (n-3));
}
}
}
return 0;
}