text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; cin >> n >> a >> b >> c; n <<= 1; int res = 0; for (int i = 0; i <= b; ++i) for (int j = 0; i * 2 + j * 4 <= n && j <= c; ++j) res += (n - i * 2 - j * 4 <= a); cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; int ans = 0; cin >> n >> a >> b >> c; for (int i = 0; i <= b; i++) { for (int j = 0; j <= c; j++) { int m = n - i - 2 * j; if (m >= 0 && a >= (m * 2)) ans++; } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int cnt[20005]; int d[4]; int main() { int i, j, k, n, max, v, goal; while (scanf("%d", &n) != EOF) { for (i = 1; i <= 3; i++) scanf("%d", &d[i]); max = 0; goal = n * 2; memset(cnt, 0, sizeof(cnt)); cnt[0] = 1; for (i = 1; i <= 3; i++) { if (i == 1) v = 1; else if (i == 2) v = 2; else if (i == 3) v = 4; for (j = max; j >= 0; j--) { if (cnt[j]) { for (k = 1; k <= d[i]; k++) { if (j + k * v > goal) break; cnt[j + k * v] += cnt[j]; } } } max += v * d[i]; if (max > goal) max = goal; } printf("%d\n", cnt[goal]); } return 0; }
#include <bits/stdc++.h> using namespace std; long long ans = 0, n, b, c, i, j, x, y; int main() { scanf("%lld%lld%lld%lld", &n, &x, &y, &c); b = x / 2 + y; for (i = 0; i <= b; i++) for (j = 0; j <= c; j++) if (i + j * 2 == n) { if (j * 2 == n) { ans++; continue; } if (max(x / 2, y) >= i) ans += min(i + 1, min(x / 2, y) + 1); else ans += min(x / 2, y) - (i - max(x / 2, y)) + 1; } printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c; long long ans; int main() { cin >> n >> a >> b >> c; for (int i = 0; i <= c && 2 * i <= n; i++) for (int j = 0; j <= b && 2 * i + j <= n; j++) if ((n - 2 * i - j) * 2 <= a) ans++; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> a >> b >> c; int ans = 0; for (int i = 0; i <= c; ++i) { if (i * 2 > n) continue; for (int j = 0; j <= b; j++) { if (n - (i * 2 + j) >= 0 && (n - (i * 2 + j)) * 2 <= a) { ans++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { int n, a, b, c, cnt = 0; scanf("%d %d %d %d", &n, &a, &b, &c); for (int i = 0; i <= a; i += 2) { int vol = 0; vol += i / 2; if (vol == n) { cnt++; break; } for (int j = 0; j <= b; j++) { int vol1 = vol; vol1 += j; if (vol1 == n) { cnt++; break; } if (vol1 % 2 == n % 2) { if (vol1 + 2 * c >= n) { cnt++; } } } } printf("%d", cnt); return; } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int a, b, c, n, ans; int main() { int i, t, j, w; while (scanf("%d%d%d%d", &n, &a, &b, &c) != EOF) { ans = 0; t = n; for (i = 0; i <= c; ++i) { t = n; t -= (i * 2); if (t < 0) break; if (t == 0) { ans++; break; } for (j = 0; j <= a; j += 2) { w = t; w -= j / 2; if (w < 0) break; if (w == 0) { ans++; break; } if (w <= b) { ans++; } } } printf("%d\n", ans); } }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; while (cin >> n >> a >> b >> c) { int count = 0; for (int i = 0; i <= c; i++) { for (int j = 0; j <= b; j++) { if ((n - 2 * i - j) * 2 <= a && (n - 2 * i - j) >= 0) count++; } } cout << count << endl; } }
#include <bits/stdc++.h> int main() { int n, a, b, c, sum; scanf("%d%d%d%d", &n, &a, &b, &c); int count = 0; int i, j; for (i = 0; i <= a; i++) { if (i % 2) continue; for (j = 0; j <= b; j++) { sum = 0; sum = (n) - (int)(i * 0.5) - (j * 1); if (sum < 0) continue; if ((sum % 2 == 0) && ((sum / 2) <= c)) count++; } } printf("%d", count); return 0; }
#include <bits/stdc++.h> using namespace std; long long int n, a, b, c, ans; int main() { cin >> n >> a >> b >> c; for (long long int i = 0; i <= a; i += 2) { if (i / 2 == n) { ans++; goto next; } if ((n - (i / 2)) % 2 == 0) { for (long long int j = 0; j <= b; j += 2) if (n - (i / 2) - j >= 0 && (n - (i / 2) - j) / 2 <= c) ans++; goto next; } if ((n - (i / 2)) % 2 == 1) { for (long long int j = 1; j <= b; j += 2) if (n - (i / 2) - j >= 0 && (n - (i / 2) - j) / 2 <= c) ans++; } next:; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; long long ans = 0; cin >> n >> a >> b >> c; n += n; for (int i = 0; i <= b; ++i) for (int j = 0; j <= c; ++j) { int k = (n - i * 2 - j * 4); if (k >= 0 && k <= a) ++ans; } cout << ans; }
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n; cin >> n; int a, b, c; cin >> a >> b >> c; int ans = 0; for (int x = 0; x <= a; x++) for (int y = 0; y <= b; y++) { if (x % 2) continue; int l = x * 0.5 + y; int req = n - l; if (req % 2 || req < 0) continue; req /= 2; if (req <= c) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, ans = 0; scanf("%d%d%d%d", &n, &a, &b, &c); for (int i = 0; i <= a && i / 2 < n; i += 2) { int nn = n - i / 2, miny, maxy; if ((nn & 1) && !b) continue; maxy = min(c, nn >> 1); if (nn & 1) { int bb = b - 1; --nn; miny = max(0, nn - bb >> 1); if (nn - bb > 0 && (nn - bb) & 1) ++miny; if (miny <= maxy) ans += (maxy - miny + 1); } else { miny = max(0, nn - b >> 1); if (nn - b > 0 && (nn - b) & 1) ++miny; if (miny <= maxy) ans += (maxy - miny + 1); } } if (a / 2 >= n) ++ans; printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, cnt = 0; cin >> n >> a >> b >> c; for (int i = 0; i <= c; i++) { int mx = min(b, n - i * 2); int mn = max(n - i * 2 - a / 2, 0); if (mx >= mn) cnt += mx - mn + 1; } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; cin >> n >> a >> b >> c; int ans = 0; for (int i = 0; i <= a; i += 2) { for (int j = 0; j <= c; j++) { if (n - (i / 2 + j * 2) <= b && n - (i / 2 + j * 2) >= 0) { ans++; } } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; cin >> n >> a >> b >> c; n *= 2; long long ans = 0; for (int i = 0; i <= c; ++i) { int temp = n - 4 * i; if (temp < 0) break; if (a == 0 && temp % 2) { if (temp % 2 == 0) { if (b * 2 + a >= temp) ++ans; } } else { int d = min(temp / 2, b); int e = max(temp - a + 1 >> 1, 0); if (d >= e) ans += d - e + 1; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, count = 0; cin >> n >> a >> b >> c; for (int i = 0; i <= a; i = i + 2) { for (int j = 0; j <= b; j++) { if ((n - i / 2 - j) >= 0 && (n - i / 2 - j) % 2 == 0 && (n - i / 2 - j) / 2 <= c) count++; } } cout << count; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; int ans = 0; cin >> n >> a >> b >> c; for (int i = 0; i <= b; i++) { for (int j = 0; j <= c; j++) { int t = n - i - 2 * j; if (t >= 0 && t <= 0.5 * a) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, i, j, k, a, b, c, ans; int main() { scanf("%d%d%d%d", &n, &a, &b, &c); a = a / 2; for (i = 0; i <= a; i++) for (j = 0; j <= b; j++) if (i + j <= n && i + j + 2 * c >= n && (n - i - j) % 2 == 0) ans++; printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, a, b, c, ret = 0, t; scanf("%d %d %d %d", &n, &a, &b, &c); n *= 10; for (i = 0; i <= a; i++) for (j = 0; j <= b; j++) { t = (i * 5); t += (j * 10); if (n - t < 0) continue; if ((n - t) % 20 == 0 && (n - t) / 20 <= c) ret++; } printf("%d\n", ret); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; cin >> n >> a >> b >> c; int ans = 0; for (int i = 0; i <= min(a, 2 * n); i += 2) { for (int j = 0; j <= min(b, n - i / 2); ++j) { int k = min(c, (n - i / 2 - j) / 2); if (i / 2 + j + 2 * k == n) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, n; cin >> n >> a >> b >> c; int res = 0; for (int i = 0; i <= a; i += 2) { for (int j = 0; j <= c; j++) { if (j * 2 + i / 2 > n) break; else if (j * 2 + i / 2 + b >= n) res++; } } cout << res; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c; int main() { cin >> n >> a >> b >> c; int cnt = 0; for (int i = 0; i <= c && 2 * i <= n; i++) for (int j = 0; j <= b && 2 * i + j <= n; j++) { int s = n - (2 * i + j); if (2 * s <= a) cnt++; } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-12; int bots[3]; long long mem[10001][3]; long long solve(int left, int cur) { if (cur == 3) return left == 0 ? 1LL : 0LL; if (left < 0) return 0LL; long long &ret = mem[left][cur]; if (ret < 0LL) { ret = 0LL; if (cur == 0) { for (int i = 0; i <= bots[0]; i += 2) { ret += solve(left - i / 2, cur + 1); } } else if (cur == 1) { for (int i = 0; i <= bots[1]; ++i) { ret += solve(left - i, cur + 1); } } else { assert(cur == 2); for (int i = 0; i <= bots[2]; ++i) { ret += solve(left - 2 * i, cur + 1); } } } return ret; } int main(void) { int n; cin >> n; cin >> bots[0] >> bots[1] >> bots[2]; for (int i = 0; i < (10001); ++i) for (int j = 0; j < (3); ++j) mem[i][j] = -1LL; cout << solve(n, 0) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long ans = 0, n, a, b, c; cin >> n >> a >> b >> c; for (long long i = 0; i <= c; i++) { for (long long j = 0; j <= b; j++) { long long k = (n - 2 * i - j) * 2; if (k >= 0 & k <= a) ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int N, T, M, K; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, a, b, c; cin >> n >> a >> b >> c; int ans = 0; for (int i = 0; i <= a; i++) { for (int j = 0; j <= b; j++) { double sum = (double)n - (0.5) * (double)i - (1.0) * (double)j; if (floor(sum) == ceil(sum)) { if (sum >= 0 && (int)sum % 2 == 0 && sum / 2 <= c) { ans++; } } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int ans = 0; int main() { int n, a, b, c, i, j, s; cin >> n >> a >> b >> c; for (i = 0; i <= c; i++) { s = i * 2; if (s > n) break; for (j = 0; j <= b; j++) { if (s + j > n) break; if ((n - s - j) * 2 <= a) ans++; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, a, b, c, count = 0, flag = 1; cin >> n >> a >> b >> c; for (int i = -1; i < a; ++i) if ((i + 1) % 2 == 0) for (int k = -1; k < c; ++k) if ((n - (i + 1) * 0.5 - (k + 1) * 2 >= 0) && (n - (i + 1) * 0.5 - (k + 1) * 2 <= b)) { count++; } cout << count; return 0; }
#include <bits/stdc++.h> const int MAXN = 11000; long long f[MAXN], g[MAXN]; int main() { int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c); memset(f, 0, sizeof(f)); for (int i = 0; i <= b && i <= n; i++) { f[i] = 1; } memset(g, 0, sizeof(g)); for (int i = 0; i <= b && i <= n; i++) { for (int j = 0; j <= c && i + j * 2 <= n; j++) { g[i + j * 2] += f[i]; } } long long res = 0LL; for (int i = 0; i <= n; i++) { if ((n - i) * 2 <= a) { res += g[i]; } } printf("%lld\n", res); return 0; }
#include <bits/stdc++.h> using namespace std; map<int, int> mp; map<int, int>::iterator mt; int main() { int n, a, b, c; cin >> n >> a >> b >> c; int x, y, z = 0; n = 2 * n; for (x = 0; x <= a; ++x) for (y = 0; y <= b; ++y) { int temp = x + 2 * y; mp[temp]++; } int sz = mp.size(); int arr1[sz], cnt[sz]; int i = 0; for (mt = mp.begin(); mt != mp.end(); mt++) { arr1[i] = (*mt).first; cnt[i] = (*mt).second; i++; } vector<int> tz; for (z = 0; z <= c; z++) tz.push_back(n - 4 * z); int ans = 0; for (int j = 0; j < (int)tz.size(); j++) { int num = tz[j]; int id = -1; int left = 0, right = i - 1, middle; while (left <= right) { middle = (left + right) / 2; if (arr1[middle] == num) { id = middle; break; } else if (arr1[middle] < num) { left = middle + 1; } else { right = middle - 1; } } if (id != -1) { ans += cnt[id]; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { unsigned int n, a, b, c, cnt, i, j; while (cin >> n >> a >> b >> c) { cnt = 0; for (i = 0; i <= b; i++) { for (j = 0; j <= c; j++) { if ((2 * (n - i - 2 * j)) <= a) { cnt++; } } } cout << cnt << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, s = 0; cin >> n >> a >> b >> c; bool f = 0; for (int i = 0; i < c + 1; i++) { for (int j = 0; j < b + 1; j++) { if (n - 2 * i - j >= 0 && n - 2 * i - j <= a / 2) { s += 1; f = 1; } } } if (f == 0) { cout << 0 << "\n"; } else { cout << s << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c, s; int main() { cin >> n >> a >> b >> c; int s = 0; int i; for (i = 0; i <= min(int(n / 2), c); i++) { if (min(n - i * 2, b) - max(n - int(a / 2) - i * 2, 0) >= 0) s += min(n - i * 2, b) - max(n - int(a / 2) - i * 2, 0) + 1; } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, ans = 0; cin >> n >> a >> b >> c; for (int i = 0; i <= b; i++) { for (int j = 0; j <= c; j++) { if (2 * (n - i - 2 * j) <= a && n >= i + 2 * j) ans++; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { ios::sync_with_stdio(0); cin.tie(0); double a, b, c; long long n, ans = 0; cin >> n >> a >> b >> c; for (int i = 0; i <= a; i++) for (int k = 0; k <= b; k++) { double sum = n - 0.5 * i - k; if (sum >= 0) { sum /= 2.0; if (!(sum > (long long)sum) && sum <= c) { ans += 1; } } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, ans = 0; cin >> n >> a >> b >> c; n = n * 2; for (int i = 0; i <= c && i <= n / 4; i++) for (int j = 0; j <= b && j <= (n - 4 * i) / 2; j++) { if (n - i * 4 - j * 2 <= a) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; bool sortbyfirstandsec(const pair<int, int> &a, const pair<int, int> &b) { if (a.first == b.first) return (a.second > b.second); return a.first < b.first; } long long fact(long long int a, long long int b) { if (b == 0) return a; else return fact(b, a % b); } int main() { long long int n, m, i, j, k, l, w = 0, a, b, c, y, p; cin >> n >> a >> b >> c; a = a / 2; for (i = 0; i <= c; i++) { if (n - 2 * i <= a + b) { for (j = 0; j <= b; j++) { if (n - 2 * i - j <= a && n - 2 * i - j >= 0) { w++; } } } } cout << w; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; cin >> n >> a >> b >> c; long long res = 0; for (int i = 0; i <= a; ++i) { for (int j = 0; j <= b; ++j) { if (2 * n - i - 2 * j >= 0 && !((2 * n - i - 2 * j) % 4) && 2 * n - i - 2 * j <= 4 * c) { ++res; } } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; while (cin >> n >> a >> b >> c) { int ans = 0; for (int i = 0; i <= b; i++) { for (int j = 0; j <= c; j++) { int t = n - i - 2 * j; if (t >= 0 && t <= 0.5 * a) ans++; } } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef struct { int a, b, c; int ways; } state; int main() { int N, a, b, c; scanf("%d %d %d %d", &N, &a, &b, &c); int ways = 0; for (int cc = 0; cc <= min(N / 2, c); cc++) { if (cc * 2 > N) break; for (int bb = 0; bb <= min(N - cc * 2, b); bb++) { if (cc * 2 + bb > N) break; if ((N - cc * 2 - bb) * 2 <= a) ways++; } } printf("%d", ways); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; long long res = 0; cin >> n >> a >> b >> c; n *= 2; for (int ic = (0); ic <= (min(c, n / 4)); ++ic) for (int ib = (min(b, (n - 4 * ic) / 2)); ib >= (0); --ib) if (n - 4 * ic - 2 * ib <= a) res++; else break; cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n; int main() { int a, b, c; cin >> n >> a >> b >> c; n *= 2; long long ans = 0; for (int i = 0; i <= a; i++) { for (int j = 0; j <= b; j++) { int nn = n - i * 1 - j * 2; if (nn < 0) continue; if (nn % 4 == 0) { if (nn / 4 <= c) ans++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long ans = 0, n, b, c, i, j, x, y; int main() { scanf("%lld%lld%lld%lld", &n, &x, &y, &c); b = x / 2 + y; for (i = 0; i <= b; i++) for (j = 0; j <= c; j++) if (i + j * 2 == n) { if (j * 2 == n) { ans++; continue; } if (max(x / 2, y) >= i) { ans += min(i + 1, min(x / 2, y) + 1); } else { ans += min(x / 2, y) - (i - max(x / 2, y)) + 1; } } printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c; int calc(int x) { if (x == 0) return 1; if (a * 0.5 + b < x) return 0; return min(x, a / 2) - max(0, (x - b)) + 1; } int main() { scanf("%d%d%d%d", &n, &a, &b, &c); int tot = 0; for (int i = 0; i * 2 <= n && i <= c; ++i) { tot += calc(n - i * 2); } printf("%d\n", tot); return 0; }
#include <bits/stdc++.h> int main() { int n, a, b, c, i, j, cnt = 0; scanf("%d%d%d%d", &n, &a, &b, &c); n = n * 2; for (i = 0; i <= b && (i << 1) <= n; i++) for (j = 0; j <= c && (i << 1) + (j << 2) <= n; j++) if (n - i * 2 - j * 4 <= a) cnt++; printf("%d\n", cnt); }
#include <bits/stdc++.h> using namespace std; int vet[3], n, a, b, c, cont; void analisa(int valor) { int help = 0; while (valor - 2 >= 0) { valor = valor - 2; help++; if (vet[0] <= a && valor <= b && help <= c) cont++; } } int main() { scanf("%d %d %d %d", &n, &a, &b, &c); vet[0] = n * 2; cont = vet[1] = vet[2] = 0; if (vet[0] <= a) cont++; while (vet[0] != 0) { vet[0] = vet[0] - 2; vet[1]++; if (vet[0] <= a && vet[1] <= b && vet[2] <= c) cont++; if (vet[1] >= 2) analisa(vet[1]); } printf("%d", cont); return 0; }
#include <bits/stdc++.h> int n, a, b, c; int main() { scanf("%d %d %d %d", &n, &a, &b, &c); int x, y, z; int res = 0; int d; for (z = (n - b - a / 2) / 2, z >= 0; z <= n / 2, z <= c; z++) for (y = n - 2 * z - a / 2; (y <= b) && (y <= n - 2 * z); y++) { if (y < 0) y = -1; else if (z < 0) z = -1; else { d = n - 2 * z - y; if ((d >= 0) && (2 * d <= a)) res++; } } printf("%d\n", res); }
#include <bits/stdc++.h> char a[1000][100]; char b[1000][100]; int main() { int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c); int rez = 0; for (int i = 0; i <= c; i++) for (int j = 0; j <= b; j++) { if ((n - i * 2 - j) * 2 <= a && n - i * 2 - j >= 0) rez++; } printf("%d", rez); }
#include <bits/stdc++.h> using namespace std; int n, a, b, c, i, j, an; int main() { scanf("%d%d%d%d", &n, &a, &b, &c); an = 0; for (i = 0; i <= c; ++i) for (j = 0; j <= b; ++j) if (i + i + j <= n && (n - i - i - j) * 2 <= a) ++an; printf("%d\n", an); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c, ans = 0; int main() { cin >> n >> a >> b >> c; a /= 2; if (a > b) swap(a, b); for (int i = 0; i < c + 1; i++) if (i * 2 <= n && a + b + i * 2 >= n) { if (i * 2 < n) ans += min(a, n - i * 2) - max(0, n - i * 2 - b) + 1; else ans++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int n, m; long long kol = 0; int a, b, c; cin >> n >> a >> b >> c; for (int z = 0; z < c + 1; z++) { for (int k = 0; k < b + 1; k++) { int i = 2 * n - 2 * k - 4 * z; if (i <= a && i >= 0) kol++; } } cout << kol; return 0; }
#include <bits/stdc++.h> using namespace std; long long ans = 0, n, b, c, i, j, x, y; int main() { scanf("%lld%lld%lld%lld", &n, &x, &y, &c); b = x / 2 + y; for (i = 0; i <= b; i++) { for (j = 0; j <= c; j++) { if (i + j * 2 == n) { if (j * 2 == n) { ans++; continue; } if (max(x / 2, y) >= i) ans += min(i + 1, min(x / 2, y) + 1); else ans += min(x / 2, y) - (i - max(x / 2, y)) + 1; } } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-6; const int inf = 2147483647; const int maxn = 10000; int n, a, b, c; int ans; int main() { scanf("%d%d%d%d", &n, &a, &b, &c); int d = a / 2; for (int i = 0; i <= c && n - 2 * i >= 0; i++) { int res = n - 2 * i; if (d + b < res) continue; for (int j = 0; j <= b; j++) { int rr = res - j; if (rr <= d && rr >= 0) ans++; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c, kol = 0; int main() { scanf("%d%d%d%d", &n, &a, &b, &c); for (int i = 0; i <= a; i += 2) { for (int j = 0; j <= b; j++) if ((n - i / 2 - j) >= 0 && (n - i / 2 - j) % 2 == 0 && (n - i / 2 - j) / 2 <= c) kol++; } printf("%d", kol); }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a, b, c, result = 0, i, x, y, j = 0; cin >> n >> a >> b >> c; for (i = 0; i <= min(n, a / 2); i++) { x = min(c, (n - i) / 2); y = min(i + b, n); if (y - (n - x * 2) / 2 >= 0) { if (y >= n - x * 2) result += (y - (n - x * 2)) / 2 + 1; } } cout << result; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { double a, b, c, i, j, k, l, m, n, t, ans = 0; cin >> n >> a >> b >> c; double aa = a * .5; t = 0; for (j = 0; j <= b; j++) { for (k = 0; k <= c; k++) { t = j * 1 + k * 2; m = n - t; if (m < 0) { continue; } else if (m >= 0) { if (aa >= m) ans++; } } } long long int answ = (double)(ans); cout << answ << endl; }
#include <bits/stdc++.h> long n; long long f[4][20005] = {0}, a[4] = {0}, b[4] = {0, 1, 2, 4}; int main() { long i, j, k; scanf("%I64d%I64d%I64d%I64d", &n, &a[1], &a[2], &a[3]); n = n * 2; f[0][0] = 1; for (i = 1; i <= 3; i++) for (k = n; k >= 0; k--) for (j = 0; j * b[i] <= k && j <= a[i]; j++) f[i][k] += f[i - 1][k - j * b[i]]; printf("%I64d\n", f[3][n]); return (0); }
#include <bits/stdc++.h> using namespace std; long n, a, b, c; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> a >> b >> c; swap(a, c); c = c / 2; long ans = 0; for (int i = 0; i <= a * 2; i += 2) { if (i > n) break; if (b + c < n - i) { continue; } long need = n - i; long cur = min(min(min(b + 1, c + 1), b + c - need + 1), need + 1); ans += cur; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, con = 0; cin >> n >> a >> b >> c; double res; for (int c1 = 0; c1 <= b; c1++) for (int c2 = 0; c2 <= c; c2++) { res = c1 * 1 + c2 * 2; if (res <= n) if (double(a) * 0.5 >= (n - res)) con++; } cout << con << endl; return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { long long int n, a, b, c, c1 = 0; cin >> n >> a >> b >> c; for (long long int i = 0; i <= b; i++) { for (long long int j = 0; j <= c; j++) { long long int x = 2 * (n - (2 * j) - i); if (x >= 0 && x <= a) c1++; } } cout << c1; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, b, c; cin >> n >> a >> b >> c; long long sum; long long count = 0; if (a / 2 + b + 2 * c >= n) for (int i = 0; i <= a; i += 2) for (int j = 0; j <= b; j++) { sum = n - (i * 1 / 2 + j); if (sum < 0 || sum & 1) continue; if (sum <= 2 * c) { count++; } } cout << count; }
#include <bits/stdc++.h> using namespace std; int rec(double litr, int a, int b, int c) { if (!litr) return 1; if (litr < 0) return 0; int ret = 0; if (a) ret += rec(litr - 0.5, a - 1, b, c); if (b) ret += rec(litr - 1, a, b - 1, c); if (c) ret += rec(litr - 2, a, b, c - 1); return ret; } int main() { int a, b, c, n; scanf("%d %d %d %d", &n, &a, &b, &c); int ans = 0, lo, hi, mid; for (int i = 0; i < c + 1; i++) { for (int j = 0; j < b + 1; j++) { if (i * 2 + j * 1 > n) break; lo = 0, hi = a; bool found = false; double compute; while (lo + 1 < hi) { mid = (lo + hi) / 2; compute = (i * 2 + j * 1. + mid * 0.5); if (compute == n) { found = true; break; } if (compute > n) hi = mid; else lo = mid; } compute = (i * 2 + j * 1. + lo * 0.5); if (compute == n) found = true; compute = (i * 2 + j * 1. + hi * 0.5); if (compute == n) found = true; if (found) ans++; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, i, j, k, x = 0; scanf("%d%d%d%d", &n, &a, &b, &c); for (i = min(c, n / 2); i >= 0; i--) { if (i * 2 + b + a / 2 < n) break; for (j = min(b, n - 2 * i); j >= 0; j--) { if (i * 2 + j + a / 2 < n) break; for (k = min(a - a % 2, (n - 2 * i - j) * 2); k >= 0; k = k - 2) { if (i * 2 + j + k / 2 < n) break; if (n == i * 2 + j + k / 2) x++; } } } printf("%d", x); return 0; }
#include <bits/stdc++.h> using namespace std; long long int m, n, c, d, j, k, l, r, x, t, y, u, z, i, e, f, g, h, a = 1, b; int main() { cin >> n >> a >> b >> c; if ((a / 2 + b + c * 2) >= n) { for (i = 0; i <= a; i += 2) { for (j = 0; j <= b; j++) { d = n - i / 2 - j; if (d < 0 || d & 1) continue; if (d <= c * 2) e++; } } } cout << e; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c, ans = 0; int main() { cin >> n >> a >> b >> c; int nb = b; b += a / 2; for (int i = 0; i <= b; i++) { if (i > n) break; for (int j = 0; j <= c; j++) { if (j * 2 + i > n) break; if (j * 2 + i == n) { for (int k = 0; k * 2 <= a && k <= i; k++) if (i - k <= nb) ans++; } } } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; void sor(vector<long long> &x) { sort(x.begin(), x.end()); } void rev(vector<long long> &x) { reverse(x.begin(), x.end()); } long long gcd(long long x, long long y) { if (y == 0) { return x; } return gcd(y, x % y); } list<long long> a[5]; void bfs(int src) { queue<int> q; bool *vis = new bool[5 + 1]{0}; q.push(src); vis[src] = true; while (!q.empty()) { int node = q.front(); cout << node << " "; q.pop(); for (int n : a[node]) { if (!vis[n]) { q.push(n); vis[n] = true; } } } } long long max(long long x, long long y) { if (x > y) { return x; } else { return y; } } long long min(long long x, long long y) { if (x > y) { return y; } else { return x; } } void primeFactors(long long n, vector<long long> &vec) { while (n % 2 == 0) { vec.push_back(2); n = n / 2; } for (long long i = 3; i <= sqrt(n); i = i + 2) { while (n % i == 0) { vec.push_back(i); n = n / i; } } if (n > 2) vec.push_back(n); } long long lcm(long long x, long long y) { return x * y / gcd(x, y); } long long g(long long x) { for (long long i = 2; i <= sqrt(x); i++) { if (x % i == 0) { return i; } } return 0; } long long countDivisors(long long n) { long long cnt = 0; for (long long i = 1; i <= sqrt(n); i++) { if (n % i == 0) { if (n / i == i) cnt++; else cnt = cnt + 2; } } return cnt; } long long bina(vector<long long> a, long long n, long long m) { long long start = 0, end = n - 1; long long c = 0; if (m >= a[n - 1]) { return n; } while (start <= end) { long long mid = (start + end) / 2; if (m >= a[mid]) { c = mid + 1; start = mid + 1; } else { end = mid - 1; } } return c; } long long binarySearch(vector<long long> arr, long long l, long long r, long long x) { if (r >= l) { long long mid = l + (r - l) / 2; if (arr[mid] == x) return mid; if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); return binarySearch(arr, mid + 1, r, x); } return 0; } int subArraylen(long long arr[], long long n, long long K) { unordered_map<int, int> mp; mp[arr[0]] = 0; for (int i = 1; i < n; i++) { arr[i] = arr[i] + arr[i - 1]; mp[arr[i]] = i; } int len = INT_MAX; for (int i = 0; i < n; i++) { if (arr[i] < K) continue; else { int x = arr[i] - K; if (x == 0) len = min(len, i); if (mp.find(x) == mp.end()) continue; else { len = min(len, i - mp[x]); } } } return len; } long long prime(long long n) { for (long long i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return i; } } return 0; } long long nextPowerOf2(long long n) { long long p = 1; if (n && !(n & (n - 1))) return n; while (p < n) p <<= 1; return p; } long long countBits(long long number) { return (long long)log2(number) + 1; } long long comb(long long c, long long n) { long long num = 1, d = 1; for (long long i = c; i > max(n, c - n); i--) { num *= i; } for (long long i = 2; i <= min(n, c - n); i++) { d *= i; } return (num / d); } void solve() { long long n, a, b, c; cin >> n >> a >> b >> c; long long ans = 0; for (long long i = 0; i < a + 1; ++i) { for (long long j = 0; j < b + 1; ++j) { if (i % 2 == 0 && (n - 0.5 * i - j) >= 0 && ((n - j - int(0.5 * i)) % 2) == 0 && (n - j - 0.5 * i) / 2 <= c) { ans++; } } } cout << ans; } vector<long long> adj[105]; long long mat[105]; void dfs(long long v, long long p) { mat[v] = mat[p] + 1; for (auto u : adj[v]) if (u != p) dfs(u, v); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; t = 1; for (long long tt = 0; tt < t; ++tt) { solve(); } return 0; }
#include <bits/stdc++.h> int main() { int n, a, b, c; scanf("%d %d %d %d", &n, &a, &b, &c); int cnt = 0; for (int i = 0; i <= a / 2; i++) { for (int j = 0; j <= c; j++) { int val = n - i - j * 2; if (val >= 0 && val <= b) cnt++; } } printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> int main() { int n, a, b, c, countx = 0; scanf("%d %d %d %d", &n, &a, &b, &c); for (int i = 0; i <= c; i++) for (int j = 0; j <= b; j++) if (2 * (n - 2 * i - j) <= a && 2 * (n - 2 * i - j) >= 0) countx++; printf("%d", countx); }
#include <bits/stdc++.h> int main() { int i, j, k, a, b, c; int n; scanf("%d %d %d %d", &n, &a, &b, &c); getchar(); int target = n; long long result = 0; for (i = 0; i <= a; i += 2) { target = n; target = target - (i / 2); if (target == 0) { result++; break; } if (target < 0) break; int target1; for (j = 0; j <= b; j++) { target1 = target; target1 = target1 - j; if (target1 == 0) { result++; break; } if (target1 < 0 || target1 % 2) continue; if (target1 <= 2 * c) { result++; } } } printf("%lld\n", result); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c); int cnt = 0; for (int i = (0); i <= (a); ++i) { for (int j = (0); j <= (b); ++j) { if ((2 * n - i - 2 * j) % 4 == 0 && (2 * n - i - 2 * j) / 4 <= c && (2 * n - i - 2 * j) >= 0) ++cnt; } } printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, n, sum = 0, i, j; cin >> n >> a >> b >> c; a = a / 2; for (i = 0; i <= a; i++) { for (j = 0; j <= c; j++) { int s = n - i - j * 2; if (s >= 0 && s <= b) { sum++; } } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 1000005; const int N = 105; int main() { int n, a, b, c; cin >> n >> a >> b >> c; n *= 2; int ans = 0; for (int i = 0; i <= a; i++) { for (int j = 0; j <= b; j++) { int remain = i + 2 * j; remain = n - remain; if (remain >= 0 && remain % 4 == 0 && remain / 4 <= c) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long a, b, c, n, res = 0; int main() { setlocale(LC_ALL, ""); cin >> n >> a >> b >> c; n *= 2; for (long i = 0; i <= a; i++) { for (long j = 0; j <= b && i + j * 2 <= n; j++) { if ((n - i - j * 2) % 4 == 0 && (n - i - j * 2) / 4 <= c) { res++; } } } printf("%d", res); }
#include <bits/stdc++.h> using namespace std; const int N = 2 * 10e4 + 5; int main() { int n, a, b, c; cin >> n >> a >> b >> c; n *= 2; if (a + 2 * b + 4 * c < n) { cout << "0"; return 0; } int ans = 0; for (int i = 0; i <= a; i += 2) { for (int j = 0; j <= b; j++) { int r = n - i - 2 * j; if (r % 4 == 0 && r <= 4 * c && r >= 0) ans++; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; while (~scanf("%d%d%d%d", &n, &a, &b, &c)) { int ans = 0; for (int i = 0; i <= b; i++) { for (int j = 0; j <= c; j++) { int tmp = n - i - j * 2; if (tmp >= 0 && tmp <= 0.5 * a) ans++; } } printf("%d\n", ans); } }
#include <bits/stdc++.h> static constexpr int MAXN = 1e6 + 10; int main() { int n, a, b, c; std::cin >> n >> a >> b >> c; long long answer = 0; for (int i = 0; i <= std::min(c, n / 2); i++) { for (int j = 0; j <= std::min(b, n); j++) { int have = 2 * i + j; int need = n - have; if (need < 0) continue; if (a >= need * 2) { answer++; } } } std::cout << answer << std::endl; return EXIT_SUCCESS; }
#include <bits/stdc++.h> using namespace std; long long ans = 0, n, b, c, i, j, x, y; int main() { scanf("%lld%lld%lld%lld", &n, &x, &y, &c); b = x / 2 + y; for (i = 0; i <= b; i++) { for (j = 0; j <= c; j++) { if (i + j * 2 == n) { if (j * 2 == n) { ans++; continue; } if (max(x / 2, y) >= i) ans += min(i + 1, min(x / 2, y) + 1); else ans += min(x / 2, y) - (i - max(x / 2, y)) + 1; } } } printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int num, a, b, c; scanf("%d%d%d%d", &num, &a, &b, &c); int ans = 0; for (int i = 0; i <= c; i++) { if (i * 2 > num) break; for (int j = 0; j <= b; j++) { int sum = i * 2 + j * 1; int rest = num - sum; if (rest >= 0 && rest * 2 <= a) ans++; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> int main() { int n, a, b, c, cnt = 0; scanf("%d%d%d%d", &n, &a, &b, &c); n *= 2; for (int i = 0; i <= a; i++) { for (int j = 0; j <= b; j++) { int k = (n - i - 2 * j); if (k % 4) continue; if (k / 4 > c || k / 4 < 0) continue; cnt++; } } printf("%d", cnt); return 0; }
#include <bits/stdc++.h> int main() { int n, a, b, c, i, j, res, N, rem; while (scanf("%d%d%d%d", &n, &a, &b, &c) == 4) { res = 0; rem = 0; N = 2 * n; for (i = 0; i <= b; i++) { for (j = 0; j <= c; j++) { rem = N - 2 * i - 4 * j; if (rem >= 0 && rem <= a) res++; } } printf("%d\n", res); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, a, b, c; cin >> n >> a >> b >> c; int count = 0; for (int i = 0; i < a + 1; i++) for (int j = 0; j < b + 1; j++) if (i % 2 == 0 && (n - (i / 2 + j)) % 2 == 0 && (n - (i / 2 + j)) / 2 >= 0 && (n - (i / 2 + j)) / 2 <= c) count++; cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int dp[4][2 * 10005]; int num[4]; int l[4] = {0, 1, 2, 4}; int main() { int n; while (scanf("%d", &n) == 1) { for (int i = 1; i <= 3; i++) scanf("%d", num + i); memset(dp, 0, sizeof(dp)); dp[1][0] = 1; dp[2][0] = 1; for (int i = 1; i <= num[1]; i++) dp[1][i] = 1; for (int i = 2; i <= 3; i++) { for (int j = 1; j <= 2 * n; j++) { for (int k = 0; k <= num[i] && k * l[i] <= j; k++) dp[i][j] += dp[i - 1][j - k * l[i]]; } } cout << dp[3][2 * n] << endl; } return 0; }
#include <bits/stdc++.h> const double PI = acos(-1); const double EPS = 1e-12; const int MOD = 1e9 + 7; const int INF = 1 << 30; using namespace std; int main() { int in, a, b, c; int cnt = 0, temp; cin >> in >> a >> b >> c; a /= 2; for (int i = 0; i <= a; i++) { for (int j = 0; j <= b; j++) { temp = in - i - j; if (temp < 0) break; if (temp % 2 == 0 && temp <= 2 * c) cnt++; } } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long long M = 1e5 + 1, MOD = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, a, b, c; cin >> n >> a >> b >> c; a = a * 0.5; int possible_way = 0; for (int i = 0; i <= c; i++) { int need = 2 * i; for (int j = 0; j <= b; j++) { int need1 = need + j; if (need1 > n) break; else if (n - need1 <= a) { possible_way++; } } } cout << possible_way << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cout << fixed; cout.precision(9); int n, A, B, C; cin >> n >> A >> B >> C; n *= 2; int r = 0; for (int c = 0; c <= C && 4 * c <= n; c++) for (int b = 0; b <= B && 2 * b + 4 * c <= n; b++) { if (n - 2 * b - 4 * c <= A) r++; } cout << r << endl; return 0; }
#include <bits/stdc++.h> int main() { int n, m, i, j, k, sum; int a[5] = {1, 2, 4}, b; int c1[20005], c2[20005]; while (scanf("%d", &n) != EOF) { memset(c1, 0, sizeof(c1)); memset(c2, 0, sizeof(c2)); c1[0] = 1; for (i = 0; i < 3; i++) { scanf("%d", &b); for (j = 0; j <= 2 * n; j++) { for (k = 0; k <= b && j + a[i] * k <= 2 * n; k++) { c2[j + a[i] * k] += c1[j]; } } for (j = 0; j <= 2 * n; j++) { c1[j] = c2[j]; c2[j] = 0; } } printf("%d\n", c1[2 * n]); } return 0; }
#include <bits/stdc++.h> int dp[20001][4]; int a[3]; int main() { int N, sum; scanf("%d %d %d %d", &sum, &a[0], &a[1], &a[2]); sum <<= 1; N = 3; memset(dp, 0, sizeof dp); dp[0][0] = 1; for (int n = 0; n < N; ++n) { for (int s = 0; s < sum + 1; ++s) { for (int i = 0; i < a[n] + 1; ++i) { if (s < (1 << n) * i) break; dp[s][n + 1] += dp[s - (1 << n) * i][n]; } } } printf("%d\n", dp[sum][N]); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, n, sum = 0, i, j; cin >> n >> a >> b >> c; a = a / 2; for (i = 0; i <= a; i++) { for (j = 0; j <= c; j++) { int s = n - i - j * 2; if (s >= 0 && s <= b) { sum++; } } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n; int a, b, c; int ways; int lacks; int main() { scanf("%d %d %d %d", &n, &a, &b, &c); ways = 0; n *= 2; for (int i = 0; i < c + 1; i++) { for (int j = 0; j < b + 1; j++) { lacks = n - 4 * i - 2 * j; if (lacks <= a && lacks >= 0) { ways++; ; } } } printf("%d\n", ways); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; cin >> n >> a >> b >> c; int sum = 0; for (int i = 0; i <= a; i = i + 2) { for (int j = 0; j <= b; j++) { int res = (i / 2) + (j); int diff = n - res; if (diff < 0) { break; } if (diff % 2 == 0 && diff / 2 <= c) { sum++; } } } cout << sum; }
/* 2013-08-11 09:01:51.521158 */#include <cstdio> #include <cstdlib> #include <iostream> #include <cstring> #include <algorithm> using namespace std; int n,a,b,c,ans; int main() { scanf("%d%d%d%d",&n,&a,&b,&c); ans=0; for (int i=0;i<=a;i++) if (!(i&1)) for (int j=0;j<=b;j++) { int sum=n-i/2-j; if (sum<0) continue; if (sum&1) continue; int k=sum/2; if (k>c) continue; ans++; } printf("%d\n",ans); return 0; }
#include <bits/stdc++.h> #pragma GCC optimization("O3") using namespace std; const long long inf = INT_MAX; const long long inf2 = 1e18; const long long minf = -1 * 1e9; const long long MAX = 1e5 + 5; const long long MOD = 1e9 + 7; const double pi = acos(-1.0); const double EPS = 1e-9; void init(int precision) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(precision); } inline void iofile() { freopen("input.txt", "r", stdin); } long long n, a, b, c, ans; int main() { init(10); cin >> n >> a >> b >> c; for (long long i = 0; i <= a; i++) { for (long long j = 0; j <= b; j++) { if (i & 1) continue; if (i / 2 + j <= n && n - (i / 2 + j) <= c * 2) { if ((n - i / 2 + j) % 2 == 0) ans++; } } } cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; int p[105][105], n, m, a[105], l, r, sum = 1e9, ans; int main() { cin >> n; int a1, a2, a3; cin >> a1 >> a2 >> a3; for (int i = 0; i <= min(a3, n / 2); i++) { for (int j = 0; j <= min(a2, n); j++) { if ((n - i * 2 - j) * 2 <= a1 && n - i * 2 - j >= 0) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long i, j, k, l, n, m, ans; long a, b, c; int main() { scanf("%d %d %d %d", &n, &a, &b, &c); for (i = 0; i <= b; i++) { for (j = 0; j <= c; j++) { k = (n - i - j * 2) * 2; if (k <= a && k >= 0) ans++; } } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c, res; int main() { cin >> n >> a >> b >> c; for (int i = 0; i <= min(c, n / 2); ++i) for (int j = 0; j <= min(n, b); ++j) if (n - 2 * i - j <= a / 2 && n - 2 * i - j >= 0) res++; cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; cin >> n >> a >> b >> c; int cc = 0; for (int i = 0; i <= a; i += 2) for (int j = 0; j <= b; j++) { if ((n - (i / 2) - j) % 2 == 0) if ((n - (i / 2) - j) <= c * 2) if ((n - (i / 2) - j) >= 0) cc++; } cout << cc << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, a, b, c, s, ans; int main() { ios_base::sync_with_stdio(0); cin >> n >> a >> b >> c; n *= 2; for (int i = 0; i <= c; i++) for (int j = 0; j <= b; j++) { s = 4 * i + 2 * j; s = n - s; if (s >= 0 && s <= a) ++ans; } cout << ans << endl; cin.get(); cin.get(); return 0; }
#include <bits/stdc++.h> int main() { int n, a, b, c, ways = 0; scanf("%d %d %d %d", &n, &a, &b, &c); int x = a / 2; for (int i = c * 2; i >= 0; i -= 2) { if (i == n) { ways++; } else if (i < n) { for (int j = b; j >= 0; j--) { if (i + j == n) { ways++; } else if (i + j < n) { if (i + j + x >= n) { ways++; } } } } } printf("%d\n", ways); return 0; }
#include <bits/stdc++.h> int dp[20005]; int n; int cnt[3]; int main() { int i, j, a, b, c, v, k; scanf("%d%d%d%d", &n, &cnt[0], &cnt[1], &cnt[2]); n = n * 2; for (i = 0; i <= n; i++) { dp[i] = 0; } dp[0] = 1; for (i = 0; i < 3; i++) { if (i == 0) v = 1; else if (i == 1) v = 2; else v = 4; for (j = n; j >= 0; j--) { if (dp[j] != 0) { for (k = 1; k <= cnt[i]; k++) { if (j + k * v > n) break; dp[j + k * v] = dp[j + k * v] + dp[j]; } } } } printf("%d\n", dp[n]); return 0; }