LCM Challenge(CF-236C)

本文探讨了如何找到三个不大于n的正整数,使它们的最小公倍数(LCM)达到最大值。通过分析奇数和偶数的特性,提出了在不同情况下选择数目的策略,以实现LCM的最大化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 ≤ 106) — 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.

Examples

Input

9

Output

504

Input

7

Output
210

Note

The least common multiple of some positive integers is the least positive integer which is multiple for each of them.

The result may become very large, 32-bit integer won't be enough. So using 64-bit integers is recommended.

For the last example, we can chose numbers 7, 6, 5 and the LCM of them is 7·6·5 = 210. It is the maximum value we can get.

题意:给出一个数 n,要求找三个不大于 n 的数,使得他们的最小公倍数最大

思路:

要找三个数的最小公倍数需要从后向前找

由于两个相邻奇数的最小公倍数是他们的乘积,且 奇数*奇数=偶数,因此,两个相邻奇数与他们中间的那个偶数相乘后,就是这三个数的最小公倍数,故当 n 为奇数时,最大的最小公倍数是 n*(n-1)*(n-2)

当 n 偶数时,由于 n 与 n-2 此时均为偶数,因此最大的最小公倍数不再是 n*(n-1)*(n-2),延续 n 是奇数的作法,最大的最小公倍数为 n*(n-1)*(n-3),但此时不一定是最大的,由于 n 与 n-3 之间差 3,因此 n 与 n-3 的最小公倍数是要小于两数相乘的,此时就不能用第一个偶数与前两个奇数相乘,而是要用第二个偶数与前两个奇数相乘,即 (n-1)*(n-2)*(n-3)

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 500000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
int main(){
    LL n;
    scanf("%lld",&n);
    if(n==1)
        printf("1\n");
    else if(n==2)
        printf("2\n");
    else{
        if(n%2)
            printf("%lld\n",n*(n-1)*(n-2));
        else{
            if(n%3)
                printf("%lld\n",n*(n-1)*(n-3));
            else
                printf("%lld\n",(n-1)*(n-2)*(n-3));
        }
    }
    return 0;
}

 

### LCM-LoRA-SDXL 的 Safetensors 文件及相关资源 LCM (Latent Consistency Models)[^1] 是一种基于潜在一致性模型的技术,它通过优化扩散过程中的中间状态来加速图像生成并提升质量。而 LoRA (Low-Rank Adaptation)[^2] 则是一种高效的微调方法,允许用户仅训练少量参数即可实现定制化效果。当两者结合应用于 SDXL(Stable Diffusion XL),可以显著提高生成效率和灵活性。 对于下载 LCM-LoRA-SDXL 的 `.safetensors` 文件或相关资源,以下是几个推荐的方向: #### 官方仓库与社区贡献 许多开源项目会托管在 Hugging Face 或 GitHub 上。Hugging Face 提供了一个专门用于分享机器学习模型的平台,其中包含大量由开发者上传的预训练权重文件[^3]。可以通过访问以下链接查找目标模型: - **Hugging Face Model Hub**: 使用关键词 `lcm lora sdxl safetensors` 进行搜索。 此外,在 GitHub 社区中也有不少针对 Stable Diffusion 和其变种的研究成果共享。例如某些存储库可能提供详细的教程以及配套的 `.safetensors` 权重文件。 #### 下载工具支持 如果已经定位到具体的 `.safetensors` 链接地址,则可借助命令行工具完成自动化操作。下面是一个简单的 Python 脚本示例,展示如何利用 `requests` 库从远程服务器获取二进制数据并保存至本地磁盘: ```python import requests url = "https://example.com/path/to/lcm_lora_sdxl.safetensors" response = requests.get(url) if response.status_code == 200: with open("lcm_lora_sdxl.safetensors", "wb") as f: f.write(response.content) else: print(f"Failed to download, status code {response.status_code}") ``` 请注意替换上述代码片段中的 URL 地址为实际有效的资源路径。 #### 注意事项 在加载外部提供的 `.safetensors` 文件之前,请务必确认来源可信度以防止恶意软件感染风险;同时也要遵循相应版权许可条款合理使用这些材料[^4]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值