跳到正文

题解

题解:P12037 [USTCPC 2025] 数学分析

zhangxiaoyu008约 3 分钟
原文
文章信息与版本

文章信息

发布
2025年7月21日
收录
2025年12月12日
更新
2026年9月26日
篇幅
约 3 分钟
题目
P12037

版本

  1. v1当前

题目传送门

My Blog\mathtt{My \ Blog} —— P12037 [USTCPC 2025] 数学分析

由定积分性质

定义 f(n)=∫01xnx2+1dxf(n) = \displaystyle\int_{0}^1\frac{x^n}{x^2+1}dx

则 ∫01P(x)x2+1dx\displaystyle\int_{0}^1\frac{P(x)}{x^2+1}dx 可以转化为 ∑i=0nf(i)\displaystyle\sum_{i=0}^n f(i)

然后用初中就学过的“分离系数法”。

f(n)=∫01xnx2+1dx=∫01xn+xn−2x2+1dx−∫01xn−2x2+1dx=∫01xn−2dx−∫01xn−2x2+1dx\begin{aligned} f(n) & = \displaystyle\int_{0}^1\frac{x^n}{x^2+1}dx \\ & = \displaystyle\int_{0}^1\frac{x^n + x^{n-2}}{x^2+1}dx - \displaystyle\int_{0}^1\frac{x^{n-2}}{x^2+1}dx \\ & = \displaystyle\int_{0}^1x^{n-2}dx - \displaystyle\int_{0}^1\frac{x^{n-2}}{x^2+1}dx \end{aligned}

然后我们惊奇的发现 ∫01xn−2x2+1dx\displaystyle\int_{0}^1\frac{x^{n-2}}{x^2+1}dx 就是 f(n−2)f(n - 2) 。

定义 F(x,n)=xn−1n−1F(x, n) = \displaystyle\frac{x^{n - 1}}{n - 1}

f(n)=F(1,n)−F(0,n)−f(n−2)=1n−1−f(n−2)\begin{aligned} f(n) & = F(1, n) - F(0, n) - f(n - 2) \\ & = \frac{1}{n - 1} - f(n - 2)\end{aligned}

f(0)=∫011x2+1dx=[arctan⁡x]01=arctan⁡1f(0) = \displaystyle\int_{0}^1\frac{1}{x^2+1}dx = \big[\arctan x\big]_0^1 = \arctan 1

f(1)=∫01xx2+1dx=[12ln⁡(x2+1)]01=ln⁡22f(1) = \displaystyle\int_{0}^1\frac{x}{x^2+1}dx = \left[\frac{1}{2} \ln(x ^ 2 + 1)\right]_0^1 = \frac{\ln 2}{2}

Code

C++
#include <bits/stdc++.h>‍‌
using namespace std;‍‌
const int N = 1e5 + 10;‍‌
int n, x;‍‌
double ans, f[N];‍‌
int main(‍‌)‍‌
‍‌{‍‌
	scanf("%d", &n);‍‌
	f[0] = atan(1);‍‌
	f[1] = log(2) / 2;‍‌
	for(int i = 0; i <= n; i ++) {
		scanf("%d", &x);‍‌
	‍‌	if(i > 1) f[i] = 1.0 / (i - 1) - f[i - 2];‍‌
		ans += x * f[i];‍‌
	}‍‌
	printf("%.10lf\n", ans);‍‌
	return 0;‍‌
}‍‌
原文