其他分享
首页 > 其他分享> > p2261 [CQOI2007]余数求和

p2261 [CQOI2007]余数求和

作者:互联网

传送门

分析

https://zzlzk.blog.luogu.org/solution-p2261

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int main(){
    long long Ans,n,k,le=1,ri;
    scanf("%lld%lld",&n,&k);
    Ans=n*k;
    for(;le<=n;le=ri+1){
      if(k/le)ri=min(n,k/(k/le));
        else ri=n;
      Ans-=(k/le)*((ri-le+1)*(ri+le)/2);
    }
    cout<<Ans;
    return 0;
}

标签:le,int,p2261,long,Ans,余数,include,CQOI2007
来源: https://www.cnblogs.com/yzxverygood/p/10354460.html