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 thann. 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
仅仅要这三个数中有两个数是奇数一个是偶数,最小公倍数就是这三个数的积。
#include<stdio.h>
int main()
{
long long LCM,n;
while(scanf("%lld",&n)>0)
{
if(n==1)LCM=1;
if(n==2)LCM=2;
if(n>2)
{
if(n%2)LCM=n*(n-1)*(n-2);
else
{
if(n*(n-1)*(n-2)/2<n*(n-1)*(n-3))
LCM=n*(n-1)*(n-3);
else LCM=n*(n-1)*(n-2)/2;
}
}
printf("%lld\n",LCM);
}
}

acd LCM Challenge(求1~n的随意三个数的最大公倍数)的更多相关文章

  1. tr循环,每行 2个数相加 求出和位第三个数赋值 (http://jsfiddle.net/hgeL44rz/113/)

    <table id="tb"> <tr> <th>单价</th> <th>数量</th> <th> ...

  2. A - LCM Challenge

    A - LCM Challenge Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Others ...

  3. LightOj 1215 - Finding LCM(求LCM(x, y)=L中的 y )

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1215 题意:已知三个数a b c 的最小公倍数是 L ,现在告诉你 a b  L 求最 ...

  4. acdream.LCM Challenge(数学推导)

     LCM Challenge Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit ...

  5. [codeforces 235]A. LCM Challenge

    [codeforces 235]A. LCM Challenge 试题描述 Some days ago, I learned the concept of LCM (least common mult ...

  6. Codeforces Round #146 (Div. 1) A. LCM Challenge 水题

    A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...

  7. acdream LCM Challenge (最小公倍数)

    LCM Challenge Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Others) Su ...

  8. CF235A 【LCM Challenge】

    这题好毒瘤啊 (特别是long long的坑,调了半天没调好!!)先将你特判一下小于3的话直接输出就是惹,不是的话就判断一下它能不能被2整除如果不能就直接输出n*(n-1)*(n-2)否则进行枚举枚举 ...

  9. [CF235A] LCM Challenge - 贪心

    找到3个不超过n的正整数(可以相同),使得它们的lcm(最小公倍数)最大. Solution 可以做得很优雅吧,但我喜欢(只会)暴力一点 根据质数密度分布性质,最后所取的这三个数一定不会比 \(n\) ...

随机推荐

  1. (转)javascript中return的作用

    这里面的return含有一些细节知识: 例如:onClick='return add_onclick()'与 onClick='add_onclick()'的区别 JAVASCRIPT在事件中调用函数 ...

  2. CodeIgniter目录结构

    1.1   application 是你自己的项目存放文件的目录(控制器.模型和视图等!) (1)分析application文件夹中的目录 (1.1)         cache文件是放缓存文件 (1 ...

  3. CSS块级元素与行级元素(转载)

    块元素一般都从新行开始,它可以容纳内联元素和其他块元素,常见块元素是段落标签'P".“form"这个块元素比较特殊,它只能用来容纳其他块元素. 如果没有css的作用,块元素会顺序以 ...

  4. oracle 分布式数据库

    分布式数据库的数据库链路是单向的

  5. Qt 数据库创建表失败原因之数据库关键字

    本人数据库新手,在创建表时出现问题,最后经查证,找出问题所在.下面的程序是部分节选,在创建数据库表的时候,起先使用的L24的CreateDB,经测试,一直输出 Create testResult Fa ...

  6. c语言实现灰度图转换为二值图

    将上篇得到的灰度图转换为二值图,读取像素数据,低于某一值置0,否则设置为255,为得到更好的效果不同图片应采用不同的值 /* 2015年6月2日11:16:22 灰度图转换为二值图 blog:http ...

  7. 从客户端(xxxxxxxxxxxxxxxxxxxxxx)中检测到有潜在危险的 Request.Form 值。

    在项目中用到了富文本编辑器,当将编辑器中的值从视图传递到控制器时,控制器就会向浏览器返回“从客户端(xxxxxxxxxxxxxxxxxxxxxx)中检测到有潜在危险的 Request.Form 值.” ...

  8. hdu 2079 选课时间(题目已修改,注意读题)

    http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> # ...

  9. C51的编程规范

    现在单片机的程序设计,C51已经得到广泛的推广和应用,算是单片机的主流设计程序,甚至可以说作为单片机开发人员必须要掌握的一门语言了.作为一门工具,最终的目的就是实现功能.在满足这个前提条件下,我们希望 ...

  10. Android中使用shape制作一个旋转的progressbar

    public class ZNtestResActivity extends Activity { @Override public void onCreate(Bundle savedInstanc ...