Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
48377 | 郑九熊 | 火车上的人数 | C++ | Accepted | 4 MS | 272 KB | 649 | 2023-05-27 14:41:49 |
//#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { //freopen("1519.in", "r", stdin); //freopen("1519.out", "w", stdout); int up[16]; int down[16]; int total[16]; int x, a, n, m; cin >> a >> n >> m >> x; up[1] = a; down[1] = 0; total[1] = a; for (int i = 0; i <= m; i++) { up[2] = i; down[2] = i; total[2] = a; for (int j = 3; j <= n; j++) { up[j] = up[j - 1] + up[j - 2]; down[j] = up[j - 1]; total[j] = total[j - 1] + up[j] - down[j]; } if (total[n - 1] == m) { cout << total[x] << endl; return 0; } } cout << "No answer." << endl; return 0; }