AtCoder Beginner Contest 163 D - Sum of Large Numbers(递推&找规律)
思路:
AC代码:
#include<bits/stdc++.h>
using namespace std;
const double pi=atan(1.0)*4;
typedef long long ll;
const ll mod=1e9+7;
int main(){
int n,k;
scanf("%d%d",&n,&k);
ll ans=0;
for(int i=k;i<=n+1;i++){
ans=(ans+(ll)i*(2*n-i+1)/2-(ll)i*(i-1)/2+1)%mod;
}
printf("%lld\n",ans);
return 0;
}