long solve(int x,int y) { int year[1000] = { 0 }; int num[1000] = { 0 }; year[0] = 1; long result(0); for (int i = 1;i <= y;i++) { int sum=0; for (int j = i;j > 0;j--) year[j] = year[j - 1]; year[0] = 0; if (i >= 2) for (int j = x - 1;j > 1;j--) year[0] += year[j]; year[x] = 0; if (i < x) for (int j = i;j >= 0;j--) sum += year[i]; int jj=x-1; int sub = 2; if (sum>10) while ((jj > 0) && (sub)) { if (year[jj] >= 2) year[jj] -= sub; if (year[jj] == 1) { year[jj] -= sub; sub--; } jj--; } } for (int i = 0;i < x;i++) result += (year[i] * i); return result*2; } int main() { int x, y; cin >> x >> y; cout << solve(x, y); return 0; }
点赞 评论
牛客网
牛客企业服务