Evanyou Blog 彩带

洛谷P3935 Calculation [数论分块]

  题目传送门


  格式难调,题面就不放了。

 


  分析:

  实际上这个就是这道题的升级版,没什么可讲的,数论分块搞就是了。

  Code:

 

//It is made by HolseLee on 18th Jul 2019
//Luogu.org P3935
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;

typedef long long ll;
ll l,r,ans;

int main()
{
    cin>>l>>r; l--;
    for(ll i=1,j; i<=r; i=j+1) {
        j=r/(r/i);
        ans=(ans+(r/i)*(j-i+1)%mod)%mod;
    }
    for(ll i=1,j; i<=l; i=j+1) {
        j=l/(l/i);
        ans=(ans-(l/i)*(j-i+1)%mod+mod)%mod;
    }
    cout<<ans<<'\n';
    return 0;
}

 

posted @ 2019-07-18 21:37  HolseLee  阅读(278)  评论(0编辑  收藏  举报