Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
101817 | 彭士宝 | 12序列找规律 | C++ | Wrong Answer | 1 MS | 276 KB | 559 | 2024-12-18 22:06:07 |
#include <iostream> using namespace std; int main() { int n; cin >> n; // 读取用户输入的正整数n // 根据n的奇偶性计算第n项的值 if (n % 2 == 1) { // n是奇数,第n项的值是10000减去(n-1)/2 cout << 10000 - (n - 1) / 2 << endl; } else { // n是偶数,第n项的值与第n-1项相同 // 由于我们没有存储前一项的值,我们可以简单地使用相同的公式,因为n-1是奇数 cout << 10000 - (n - 2) / 2 << endl; } return 0; }
------Input------
12
------Answer-----
9990
------Your output-----
9995