JDOJ 2785: 商之和 数论分块

Code:

#include <iostream>
#include <cstdio> 
#define setIO(s) freopen(s".in","r",stdin)
#define ll long long 
#define mod 23333333333333333 
using namespace std;
int main(){
    //setIO("input");
    long long N,L,R,x,Ans = 0;
    scanf("%lld",&N);
    for(L = R = 1;L <= N;L = R + 1) {
        x = N / L;
        R = N / x;
        Ans += (min(N,R) - L + 1) * x;
        Ans %= mod; 
    }
    printf("%lld",Ans); 
    return 0;
}

  

posted @ 2019-02-11 16:52  EM-LGH  阅读(139)  评论(0编辑  收藏  举报