acd LCM Challenge(求1~n的随意三个数的最大公倍数)
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
Output
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的随意三个数的最大公倍数)的更多相关文章
- tr循环,每行 2个数相加 求出和位第三个数赋值 (http://jsfiddle.net/hgeL44rz/113/)
<table id="tb"> <tr> <th>单价</th> <th>数量</th> <th> ...
- A - LCM Challenge
A - LCM Challenge Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others ...
- LightOj 1215 - Finding LCM(求LCM(x, y)=L中的 y )
题目链接:http://lightoj.com/volume_showproblem.php?problem=1215 题意:已知三个数a b c 的最小公倍数是 L ,现在告诉你 a b L 求最 ...
- acdream.LCM Challenge(数学推导)
LCM Challenge Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- [codeforces 235]A. LCM Challenge
[codeforces 235]A. LCM Challenge 试题描述 Some days ago, I learned the concept of LCM (least common mult ...
- Codeforces Round #146 (Div. 1) A. LCM Challenge 水题
A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...
- acdream LCM Challenge (最小公倍数)
LCM Challenge Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Su ...
- CF235A 【LCM Challenge】
这题好毒瘤啊 (特别是long long的坑,调了半天没调好!!)先将你特判一下小于3的话直接输出就是惹,不是的话就判断一下它能不能被2整除如果不能就直接输出n*(n-1)*(n-2)否则进行枚举枚举 ...
- [CF235A] LCM Challenge - 贪心
找到3个不超过n的正整数(可以相同),使得它们的lcm(最小公倍数)最大. Solution 可以做得很优雅吧,但我喜欢(只会)暴力一点 根据质数密度分布性质,最后所取的这三个数一定不会比 \(n\) ...
随机推荐
- Visual Studio写的项目在 IIS 服务器上运行的两种简单方法
首先需要PC上开启了IIS服务,相关方法网上很多,也很简单 第一种:直接在项目中操作 1.创建一个项目,然后右击选中项目,右击,单击属性,打开项目属性标签页面 如图,选择Web标签,在服务器栏目中选中 ...
- (转)XML CDATA是什么?
解析数据 XML 解析器通常情况下会处理XML文档中的所有文本. 当XML元素被解析的时候,XML元素内部的文本也会被解析: <message>This text is also pars ...
- WCF理论 【转载】
原文地址:http://blog.itpub.net/23109131/viewspace-661613/ WCF是什么? WCF是"Windows Communication Founda ...
- checking for oracle home incompatibilities failed
安装Oracle软件的过程中,报错: 出错原因: 这个错误主要是oracle上一次安装失败,而没有删除干净而留下的目录文件造成. 解决办法: 清除原先目录下的文件,再retry或者重新安装即可. 示例 ...
- ReactiveCocoa 简单使用
#pragma mark 指令 -(void) instructionDemo { // 创建使能信号 RACSignal * signal = [self.textField.rac_textSig ...
- sql用户权限
登录 1)右键根目录属性 点下面的sql server 和 windows 身份验证模式 2)安全性右键新建,选择登陆 去掉 那个"用户下次登陆是必须改密码" ,下面默认数据库改为 ...
- 研究一下uucode编码
uucode编码是把任意二进制数据转换为ascii字符的编码用于在一些只能传递文本的地方传送二进制数据uu模块提供了encode()和decode()用于将一个文件转换为uucode编码的字符文件,文 ...
- Centos7 打开80端口防火墙命令
iptables -I INPUT -p TCP --dport 80 -j ACCEPT
- Swift—下标-备
看下面的示例代码是不是使用过: var studentList: String[] = ["张三","李四","王五"] studentL ...
- android-UI组件实例大全(六)------ImageView图像视图
图像视图:ImageView 继承view类,用于在屏幕上显示任何Drawable对象,通常用来显示图片: 这里的话我们介绍一些比较常用的属性: Path 1: android:adjustViewB ...