首页 > 其他分享 >P2424

P2424

时间:2024-09-09 18:35:43浏览次数:2  
标签:上题 正解 题解 ll long P2424

1.逃课做法

第一眼看到:
感觉有点像内啥分解只因数
然后就不会了那我写这个干什么
这时,聪明的我们就想到了打表
怎么打呢?
如图:

我们可以把它分成几个块,提前打好每个块的答案
这样,我们就用普及的算法过了提高的题

2.正解

氧化钙(CaO)的怎么和上题一样

#include<cstdio>
using namespace std;
typedef long long ll;

ll sum(int n) {
    if(n<=1) return n;
    ll ans=0;
    for(ll l=1,r;l<=n;l=r+1) {
        r=n/(n/l);
        ans+=(n/l)*(l+r)*(r-l+1)/2;
    }
    return ans;
}

int main() {
    int x,y;
    scanf("%d%d",&x,&y);
    printf("%lld\n",sum(y)-sum(x-1));
    return 0;
}

题解是这样说的:here

标签:上题,正解,题解,ll,long,P2424
From: https://www.cnblogs.com/zan-mei-tai-yang/p/18405082

相关文章