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. 404 Not Find When using Owin with OAuth

    在使用Owin+OAuth时,一步一步的测试时,在用 OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = ...

  2. @CacheEvict(value = { "" })

    org.springframework.cache.annotation.CacheEvict

  3. 关于.net类型转换判断问题

    做项目时,发现这个问题,由于数据库中的字段可能为null,如果在.net程序直接转换时,比如 ltTime.Text =DateTime.Parse(dt.Rows[0]["m_Time&q ...

  4. 第一个androidAPP项目总结—ListView的上拉和下拉

    1.下拉刷新 需继承implements SwipeRefreshLayout.OnRefreshListener @Overridepublic void onRefresh() { new Wea ...

  5. 增加Android模拟器的内存

    1,在window中,打开'C:\Users\Administrator\.android\avd\4.4.2.avd\config.ini'文件(我的是win7,xp的貌似不是'Users',是'D ...

  6. 解释DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

    解释DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci 在创建数据库的时候,经常用到一句:CREATE DATABASE `tpcms` DEFAUL ...

  7. mysql文件导入到数据库load data infile into table 的使用例子

    load data infile "C:/Users/Administrator/Desktop/1.txt"into table 要一个已经存的表名 字段默认用制表符隔开 文件 ...

  8. JSP中取COOKIE中指定值得方法【转载】

    Cookie cookies[]=request.getCookies(); //读出用户硬盘上的Cookie,并将所有的Cookie放到一个cookie对象数组里面 Cookie sCookie=n ...

  9. eclipse下编译openfire3.9.1源码

    [一].下载源码 打开网址:http://www.igniterealtime.org/downloads/source.jsp 选择目前最新版本 openfire_src_3_9_1.zip 下载. ...

  10. Css3案例

    <!DOCTYPE html> <html> <meta charset=utf-> <head> <style> body{ backgo ...