#include<iostream>
using namespace std;
long long ans,n,m;
int main()
{
ios::sync_with_stdio(false); //慎用
cin>>n>>m;
if(m+1>=n*2)
{
cout<<0<<endl;return 0;
}
int b=2;
if(m%2==0) b=1;
if(n>=m)
{
ans+=(m-1+n-1)*(n-m+1)/2;
for(int i=(m+1)/2+1;i<=m-1;i++)
ans+=b,b+=2;
}
else
{
for(int i=(m+1)/2+1;i<=n;i++)
ans+=b,b+=2;
}
cout<<ans<<endl;
return 0;
}
OneCode(天梯二) C:统计和
最新推荐文章于 2023-10-22 13:54:05 发布