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\) ...
随机推荐
- python的按位运算
#coding=utf-8#"&"按位与运算,是指一个数字转化为二进制,然后这些二进制的数按位来进行与运算a=7&18print a'''首先将7转化为二进制,得到 ...
- 关于IIS部署成功后,局域网其他用户无法访问的问题解决方法
关于win7部署iis后,局域网的其他用户不能访问的问题. 在win7系统中,部署好iis后,自己本地可以发布和预览.但在局域网中的其他用户不可以访问.下面说一下这个原因. 这是因为win7自带的 ...
- java transient关键字和transaction的区别
transient:表示临时的,不会被持久化,保存进数据库 transaction:表示事务 <div style="background: #fff; color: #0ff;&qu ...
- ARGB和RGB
ARGB 一种色彩模式,也就是RGB色彩模式附加上Alpha(透明度)通道,常见于32位位图的存储结构. ARGB---Alpha,Red,Green,Blue. Alpha-图像通道 如果图形卡具有 ...
- js设置元素的onclick传参方法
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD ...
- fopen,file_get_contents,curl的区别
1. fopen /file_get_contents 每次请求都会重新做DNS查询,并不对DNS信息进行缓存.但是CURL会自动对DNS信息进行缓存.对同一域名下的网页或者图片的请求只需 ...
- iptables阻止服务器被攻击
下列规则将会阻止来自某一特定IP范围内的数据包,因为该IP地址范围被管理员怀疑有大量恶意攻击者在活动: # iptables -t filter -A INPUT -s 123.456.789.0/ ...
- DELL磁盘阵列控制卡(RAID卡)MegaCli常用管理命令汇总
新版本的 MegaCli-1.01.24-0.i386.rpm (下载地址:http://www.lsi.com/downloads/Public/MegaRAID Common Files/8.02 ...
- php 通过ip获取地理位置
<?php header('Content-Type:text/html;Charset=utf-8'); function GetIp(){ $realip = ''; $unknown = ...
- 跟我学android-搭建Android开发环境(一)
Android官网地址:http://developer.android.com/,下载和安装 AndroidSDK请按如下步骤进行: 下载ADT 和SDK:http://developer.andr ...