Let life be beautiful l|

Ginger_he

园龄:3年1个月粉丝:5关注:5

洛谷P8219题解

本文同步更新于洛谷博客

题目描述

f(x) 表示除 x 本身之外,x 的最大约数。给定 L,R,求 maxi=LR{f(i)}

题解

先感性理解,要让 x 尽量大,并且让它除 1 以外的最小约数尽量小,不难想到答案为 [L,R] 中最大偶数的一半。
R 为偶数,显然。若 R 为奇数,即证 R12R3,等价于 R3,刚好符合题目的数据范围,证毕。

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll l,r;
int main()
{
    scanf("%lld%lld",&l,&r);
    printf("%lld\n",r>>1);
    return 0;
}

本文作者:Ginger_he

本文链接:https://www.cnblogs.com/Gingerhe/p/16027696.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Ginger_he  阅读(82)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起