Mancala

  • 恢复做斯波题的传统
  • 代码:

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
long long a[14], b[14], ans = 0;
int main() {
    for (int i = 0; i < 14; i++) scanf("%lld", &a[i]);
    for (int i = 0; i < 14; i++) {
        if (!a[i]) continue;
        long long tmp = a[i] / 14;
        long long rest = a[i] % 14;
        long long res = 0;
        for (int j = 0; j < 14; j++) {
            int pos = (i + j + 1) % 14;
            b[pos] = (pos == i ? 0 : a[pos]) + tmp;
            if (j < rest) b[pos]++;
            if (!(b[pos] & 1)) res += b[pos];
        }
        ans = std::max(ans, res);
    }
    printf("%lld\n", ans);
    return 0;
}

Leave a Reply