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; }