hrbust1632 最大的最小公倍数(欧几里得)
2014-10-17 00:00
190 查看
本文出自:http://blog.csdn.net/svitter
原题:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1632
题意:给你一个数字N,让你在1~n中选三个数字,使其最小公倍数最大。
题解:水题一发。。半天没A。。呵呵呵呵。
1。相邻自然数肯定互质。
2。依据辗转相除法。。shit- -。。n和n-3如果有最大公约数肯定是3。
AC:
原题:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1632
题意:给你一个数字N,让你在1~n中选三个数字,使其最小公倍数最大。
题解:水题一发。。半天没A。。呵呵呵呵。
1。相邻自然数肯定互质。
2。依据辗转相除法。。shit- -。。n和n-3如果有最大公约数肯定是3。
AC:
//============================================================================ // Name : num.cpp // Author : vit // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> #include <stdio.h> #include <string.h> using namespace std; #define lln long long int int main() { lln n; lln ta, tb; while(~scanf("%lld", &n)) { if(n <= 2) printf("%lld\n", n); else { if(n & 1) printf("%lld\n", n*(n-1)*(n-2)); else { if(n % 3 != 0) ta =n*(n-1)*(n-3); else ta = 0; tb = (n-1)*(n-2)*(n-3); printf("%lld\n", ta > tb ? ta : tb); } } } return 0; }
相关文章推荐
- hrbust1632 最大的最小公倍数(欧几里得)
- hrbust1632 最大的最小公倍数(欧几里得)
- hrbust 1632 最大的最小公倍数
- hrbust 1632 最大的最小公倍数
- Hust oj 1632 最大的最小公倍数(简单数学)
- ACM数论之旅3---最大公约数gcd和最小公倍数lcm(苦海无边,回头是岸( ̄∀ ̄))
- 最大公约数最小公倍数
- java最小公倍数与最大公约数
- 最大公约数与最小公倍数
- 最大公约数和最小公倍数的问题
- C++第七次实验(最大公约和和最小公倍数)
- 最大公约数与最小公倍数
- c++实验7-最大公约数最小公倍数
- C++实验7--项目2:最大公约和和最小公倍数
- 求分数的最大公约与最小公倍数
- JAVA 输入两个正整数m和n,求其最大公约数和最小公倍数。 1.程序分析:利用辗除法。
- 最大公约数和最小公倍数的算法
- Num 19: 最大公约数.最小公倍数.素数的判断
- C/C++训练1---最大公约数与最小公倍数
- 最大公约数和最小公倍数的求解