Run ID:101817

提交时间: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; }