天天看點

Simple Math Problem

​​傳送門​​

思路:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 0x3f3f3f3f;


int main()
{
  ll n;
  cin>>n;
  ll x,y;
  cin>>x>>y;
  if(x+y < n)
  {
    cout<<(y+1)*y/2+(y+2+x+1+y)*x/2<<endl;
  }
  else
  {
    ll ans = (y+1)*y/2+(y+2+(n-y-1)+1+y)*(n-y-1)/2;
    ans += (n+n-(x+y-n+1)+1)*(x+y-n+1)/2;
    cout<<ans<<endl;
  }
}      

繼續閱讀