ABC051B - Sum of Three Integers
#include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int k, s, ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> k >> s; REP(x, k + 1) { REP(y, k + 1) { int z = s - x - y; if (0 <= z && z <= k) { ans++; } } } cout << ans << "\n"; return 0; }