Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
34643 | 22级廖思学 | 【S】T1 | C++ | 解答错误 | 63 | 0 MS | 252 KB | 727 | 2024-11-12 14:12:52 |
#include<bits/stdc++.h> using namespace std; #define int long long #define it __int128_t const int M=1e9+7; int l,r,sl,sr; signed main(){ scanf("%lld%lld",&l,&r); int x=sqrt(r),L=x*x,R=r,k=x*x+x; if(R<k){sl=(sl+((it)(L+R)*(R-L+1)/2%M))%M;} else{ sr=(sr+((it)(L+k)*(k-L+1)/2%M))%M; sr=(sr-((it)((R+k+1)*(R-k)/2)%M)+M)%M; } if(x%2==0)sr=(M-sr)%M; x=sqrt(l-1),L=x*x,R=l-1,k=x*x+x; if(R<k){sl=(sl+((it)(L+R)*(R-L+1)/2%M))%M;} else{ sl=(sl+((it)(L+k)*(k-L+1)/2%M))%M; sl=(sl-((it)((R+k+1)*(R-k)/2)%M)+M)%M; } if(x%2==0)sl=(M-sl)%M; // cout<<sl<<" "<<sr<<endl; int ans=(sr-sl+M)%M; printf("%lld\n",ans); return 0; }