LCM Challenge(数论)
来源:互联网 发布:java之gui编程 三 编辑:程序博客网 时间:2024/06/10 18:19
Link:http://acdream.info/problem?pid=1077
LCM Challenge
Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)
Submit Statistic Next Problem
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 than n. 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
AC code:
#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#include<cmath>#include<queue>#include<vector>#include<map>#define LL long long#define MAXN 1000010using namespace std;int main(){ LL ans,n;while(cin>>n){if(n<=2){ans=n;}else if(n%2){ans=n*(n-1)*(n-2);}else{if(n%3){ans=n*(n-1)*(n-3);}else{ans=(n-1)*(n-2)*(n-3);}}cout<<ans<<endl;}return 0; }
0 0
- LCM Challenge(数论)
- LCM Challenge(最小公倍数)
- LCM Challenge(暴力)
- Codeforces 236C LCM Challenge 数论(基础题)
- LCM Challenge
- ACdream 1077 LCM Challenge (数学题)(LCM)
- Codeforces Round #146 (Div. 1) LCM Challenge 解题报告 数论 找规律
- ACdream1077:LCM Challenge
- ACdream1077 LCM Challenge 数学题
- ACdream1077-LCM Challenge
- UVA 10791 Minimum Sum LCM (数论)
- uva 11388 - GCD LCM(数论)
- uva 10892 - LCM Cardinality(数论)
- UVA 10892 - LCM Cardinality(数论)
- UVA 10791 Minimum Sum LCM (数论)
- UVa 11388 - GCD LCM (简单数论)
- uva 10791 Minimum Sum LCM(数论)
- UVA10791 Minimum Sum LCM(数论)
- Android中Socket的实例分析(一)
- 提高写作水平的十条建议
- C#学习第九天 继承、里氏转换、集合
- leetcode-Valid Parentheses
- stdafx.h简介
- LCM Challenge(数论)
- JAVA 调用Web Service
- 定制自己的VIM
- 数据库 - 关系数据库
- 进阶_计时器(Handler+Thread实现)_150503
- 如何利用R语言计数
- 简述TCP建立连接和释放的“握手”过程
- win7 boot2docker安装gitlab和jira
- Win7下U盘安装Ubuntu14.04双系统