fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int k, s;
  7. cin >> k >> s;
  8. int count = 0;
  9. for (int x = 0; x <= k; x++)
  10. for (int y = 0; y <= k; y++)
  11. {
  12. int z = s - x - y;
  13. if (z >= 0 and z <= k)
  14. count++;
  15. }
  16. cout << count;
  17. return 0;
  18. }
Success #stdin #stdout 0s 5284KB
stdin
2 1
stdout
3