邸礼诚 • 8个月前
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void Out128(__int128 x){
if(x==0){
return;
}
int y=x%10;
Out128(x/10);
cout<<y;
}
ll l,r;
int main(){
cin>>l>>r;
ll lg=sqrt(l);
ll rg=sqrt(r);
__int128 ans=0;
for(ll i=lg;i<=rg;i++){
ll nex=(i+1)*(i+1);
ll cur=i*i;
if(cur<l){
cur=l;
}
if(nex>r){
nex=r;
}
ans=ans+(nex-cur)*i;
}
ans+=rg;
Out128(ans);
return 0;
}
评论: