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. Html.RenderAction简单用法

    一 Html.ActionLink("actionName") 调用页与当前页位于同一个控制器,可直接调用,显示对应的视图 二 Html.ActionLink("acti ...

  2. ref - 按引用传递参数

    传递的是引用 在 形参 实参前 加ref

  3. Android ScrollView 嵌套 ListView、 ListView 嵌套ScrollView Scroll事件冲突解决办法

    本人菜鸟一名,最近工作了,开始学习Android. 最近在做项目的时候,UX给了个design,大概就是下拉刷新的ListView中嵌套了ScrollView,而且还要在ScrollView中添加动画 ...

  4. 【转】Understanding and Using rem Units in CSS

    CSS units have been the subject of several articles here on SitePoint (such as A Look at Length Unit ...

  5. CSS3过渡效果实现菜单划出效果

    下载地址 这是大体上的原理,当然案例比这个多 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" & ...

  6. LINQ对List列表随机排序,取N条数据

    List<Art_Search> artList=new List<Art_Search>(); artList=artList.OrderBy(s => Guid.Ne ...

  7. C++拾遗(五)语句相关

    前缀格式与后缀格式 对于表达式:后缀如 i++ 表达式的值仍是 i,在遇到下一个顺序点后再将 i 加1.前缀 ++i 表达式的值就是(i+1),先计算表达式的值,不需要等待 顺序点. 对于类:前缀函数 ...

  8. QT学习:入门篇(三)

    头文件: #ifndef CChatDisplaySet_h #define CChatDisplaySet_h #include "QtGui/QDialog" #include ...

  9. node学习笔记-搭建node环境

    最近项目要用到node,利用空闲整理做下笔记 第一步  安装node,方式比较多,最为直接的是直接去官网     可直接从官网下载安装http://nodejs.cn/download/ 根据自己情况 ...

  10. 命令passwd报错因inode节点处理记录

    命令passwd报错因inode节点处理记录故障现象:1.修改密码时报错 passwd: Authentication token manipulation error2.添加用户报错:unable ...