0%

1033 To Fill or Not to Fill (25 分)

With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked to carefully design the cheapest route to go.

阅读全文 »

判断是否收敛

正项级数

1. 比较审敛法

若每项比一个收敛级数小,收敛;若每项比一个发散级数大,发散。

2. 比较极限

两个不同级数的项\(u_n\)\(v_n\)
\[\lim_{n\to\infty}\frac{u_n}{v_n}=l\] 若比值极限为有限非零常数:同收敛发散;
若为0(v大很多):若\(v_n\)收敛则\(u_n\)收敛;
若为\(\infty\)(v小很多):若\(v_n\)发散则\(u_n\)发散。

3. 比值

\[\lim_{n\to\infty}\frac{a_{n+1} }{a_n}=\rho\begin{cases} \rho\lt 1 收敛 \\ \rho\gt 1 发散 \\ \rho=1 不确定 \end{cases}\]

4. 根植

\[\lim_{n\to\infty}\sqrt[n]{u_n}=\rho \begin{cases} \rho \lt 1 收敛 \\ \rho \gt 1 发散 \\ \rho = 1 不确定 \end{cases}\]

交错级数

\[\sum_{n=1}^{\infty}(-1)^{n-1}u_n,(u_n\gt 0)\]\(u_n\)递减且极限为0:收敛。

常用判别方法

  1. 出现阶乘和n次方:比值法
  2. 出现大块的n次方形式:根值法
  3. 看不出来:比较法,另找一个函数

幂级数

求收敛半径和收敛域

  1. \(x\)的形式比较复杂,先用\(t\)替换。
  2. \(x^n\)前面的 \(\frac{a_{n+1} }{a_n}=\rho\)\(\sqrt[n]{a_n}=\rho\),则收敛半径为$R=| | $ 。(若\(x\)前后两项相差\(k\)次,\(\rho\)需要开\(k\)次)
  3. 验证左右端点是收敛发散。 \((-R, R)\)为收敛半径(端点开闭看前面检测)
  4. \(t\)换回去。

给函数展开成幂级数

基本形式

\[e^x=\sum_{n=0}^\infty \frac{x^n}{n!}\] \[\sin x=\sum_{n=0}^\infty \frac{(-1)^{n}x^{2n+1} }{(2n+1)!}\] \[\cos x=\sum_{n=0}^\infty \frac{(-1)^{n}x^{2n} }{(2n)!}\] \[\frac{1}{1-x}=\sum_{n=0}^\infty x^n\] \[\frac{1}{1+x}=\sum_{n=0}^\infty (-1)^nx^n\] \[\ln(1+x)=\sum_{n=1}^\infty \frac{(-1)^{n-1}x^n}{n}\] \[-\ln(1-x)=\sum_{n=1}^\infty \frac{x^n}{n}\]

没说在哪展开

  1. 分离,化简,凑成基本形式

  2. 凑不出?可以求它的导数
    假设想求\(f(x)\)的展开式:

    1. 求导为\(f'(x)\)
    2. \(f'(x)\)通过基本形式展开为幂级数
    3. \(f(x)=\int_0^xf'(t)dt+f(0)\),这里的\(f'(t)\)为幂级数
    4. 对幂级数里面进行积分,得出最终答案

这就是利用逐项可积性,所以先求导再积分并不是无用功。

\(x=a\)处展开为幂级数

  1. 分离,化简
  2. 把式子中的\(x\)凑成\(x-a\)的形式
  3. 把这部分当成整体如上方法进行展开

级数求和:求和函数

  • 分离,化简。如果能展开成很多项,看看前后项有没有关系啊能不能抵消啊
  • 凑原函数:例如\(\sum na^n=\sum (n+1)a^n-\sum a^n=\sum (a^{n+1})'-\sum a^n=(\sum a^{n+1})'-\sum a^n\),然后就可以先求和再求导
  • 借助等比数列、等差数列求和公式
  • 借助展开的基本形式
  • 对于\(\sum x^n\)凑的时候可能\(x\)的次数不太符合人意,可以考虑\(x^2\sum x^{n-2}\)之类的

1029 Median (25 分)

Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of two sequences is defined to be the median of the nondecreasing sequence which contains all the elements of both sequences. For example, the median of S1 and S2 is 13.

Given two increasing sequences of integers, you are asked to find their median.

阅读全文 »

1026 Table Tennis (30 分)

A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the smallest number. If all the tables are occupied, they will have to wait in a queue. It is assumed that every pair of players can play for at most 2 hours.

Your job is to count for everyone in queue their waiting time, and for each table the number of players it has served for the day.

阅读全文 »

1025 PAT Ranking (25 分)

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after the test. Now it is your job to write a program to correctly merge all the ranklists and generate the final rank.

阅读全文 »

\(\oint_Lf(x,y)ds\)

对弧长的线积分(第一类)
1.判断奇偶性和对称性
\(\begin{cases} 若轴对称,则偶为2倍奇为0 \\ 若关于y=x对称,则可交换xy \end{cases}\)

2.计算
参数方程
\[\begin{cases} x=x(t) \\ y=y(t) \\ \alpha\le t\le\beta \\ \int_\alpha^\beta f(x(t),y(t))\sqrt{x'^2(t)+y'^2(t)}dt \end{cases} \]

直角坐标计算
\[\begin{cases} L:y=y(x),a\le x\le b \\ \int_a^bf(x,y(x))\sqrt{1+y'^2(x)}dx\end{cases}\]

极坐标计算
\[\begin{cases} \rho=\rho(\theta) \\ \alpha\le x\le\beta \\ \int_{\alpha}^{\beta} f( \rho ( \theta ) \cos \theta, \rho ( \theta ) \sin \theta ) \sqrt { \rho^2 + \rho'^2} d \theta \end{cases} \]

一奇偶对称,二替换变量,三乘根号;
参数方程导数平方和开根号,直角坐标函数导数平方加一开根号,极坐标函数导数平方和开根号


\(\int_L f_1(x,y)dx+f_2(x,y)dy\)

对坐标的线积分(第二类)

\(\int_LPdx+Qdy=\int_L(P\cos\alpha+Q\cos\beta)ds\)

一、直接计算-定积分法

\(\int_LPdx+Qdy\)

\(\begin{cases} 直角坐标: \int_a^bP(x,\phi(x))dx+Q(x,\phi x)\phi'(x)dx\\ 参数方程:\int_\alpha^\beta P(\phi(t),\Phi(t))\phi'(t)dt+Q(\phi(t),\Phi(t))\Phi'(t)dt \end{cases}\)

直接替换求积分,记得\(d(x)\)里面的\(x\)替换后要求导。

二、格林公式

条件

  1. 区域为闭曲线,方向逆时针(正向)

  2. \(P(x,y)\)\(Q(x,y)\)处处连续有一阶偏导数(路径无关)

公式

\(\oint_L Pdx+Qdy=\iint_D(\frac{\partial Q}{\partial x}-\frac{\partial P}{\partial y})dxdy\)

注意\(P\rightarrow dx\rightarrow y\)偏导,在后面;\(Q\rightarrow dy\rightarrow x\)偏导,在前面。


已知复杂曲线,求曲线积分

曲线为\(x^2+y^2+z^2=1\)\(x+y+z=0\)的交线,则\(\oint_L (x+2y)^2ds\)为__________
直接算不好算,因此把曲线方程凑积分方程,尽量化简成常数。
1. 首先展开:\((x+2y)^2=x^2+4y^2+4y\)
2. 根据变量对称性:\(\oint x^2ds=\oint y^2ds=\oint z^2ds\)\(\oint xyds=\oint yzds=\oint xzds\)
3. 原式=\(\oint \frac{5}{3}(x^2+y^2+z^2)+\frac{2}{3}[(x+y+z)^2-(x^2+y^2+z^2)]ds\)
4. =\(2Pi\)

基本转换

使用条件

若出现\(x^2+y^2\),通常将直角坐标转换为极坐标。

转换方法

若原式为\(\iint f(x,y)dxdy\): 令\(\begin{cases} x=r\cos\theta \\ y=r\sin\theta \end{cases}\),写成\(\int d\theta \int f(r\cos\theta, r\sin\theta)rdr\)的形式,然后考虑积分范围。 \(\theta\)的范围为积分区域所占的范围,\(r\)的上界是离原点远的边界函数,下界是离原点近的边界函数。

常见边界转换

积分区域为一个圆

圆在x轴但不是原点,且与坐标轴相切

例如给定\(x^2+y^2=-2ax\),易转换为\((x-a)^2+y^2=a^2\),此时圆的边界为\(2a\cos\theta\),写成\(\int^{2a\cos\theta}_{0}frdr\)。为什么下界是0呢?因为圆与y轴相切,那么从原点出发与圆相交的线只有两个交点,原点与相对的圆上的点。

圆在y轴但不是原点,且与坐标轴相切

例如给定\(x^2+y^2=-2ay\),易转换为\(x^2+(y-a)^2=a^2\),此时圆的边界为\(2a\sin\theta\),写成\(\int^{2a\cos\theta}_{0}frdr\)

圆在原点

例如给定\(x^2+y^2=a^2\),圆的边界为\(a\cos\theta\)

函数等于它的积分加另一个函数,求函数

  1. 令积分部分等于A,对等式两边同时积分

  2. A的积分为常数(考虑乘以积分范围)

  3. 计算式子中剩余的积分,即可算出A

  4. 最后把A带入最初给的式子中,即可得到函数f(x)

形如\(f(x)=\phi(x)+\int f(x)\)

两边积分:\(A=\int \phi(x)dx+\int Adx\)

形如\(f(x,y)=\phi(x,y)+\iint_D f(x,y)dxdy\)

两边积分:\(A=\iint \phi(x,y)dxdx+\iint Adxdy\)


交换积分次序\(\theta\)\(\rho\)

例如: \[\int_{-\frac{\pi}{4} }^{\frac{\pi}{2} }d\theta\int_0^{2\cos \theta}f(\rho\cos\theta,\rho\sin\theta)\rho d\rho\]
转换成 \[\int_0^{\sqrt{2} }\rho d\rho\int_{-\frac{\pi}{4} }^{\arccos\frac{\rho}{2} }f(\rho\cos\theta,\rho\sin\theta)d\theta+\int_{\sqrt{2} }^2\rho d\rho\int_{-\arccos\frac{\rho}{2} }^{\arccos\frac{\rho}{2} }f(\rho\cos\theta,\rho\sin\theta)d\theta+\]
极坐标积分图
黑色线为\(\rho=\sqrt 2\)的曲线,左侧为第一个积分的积分区域,右侧为第二个积分的积分区域。因为要先按半径积分,而圆不是一个完整的圆,被直线切掉了一块,因此以线段画弧先积分,再加上弧右侧的积分即可。
注意,积分\(\theta\)的角度不是显而易见的常数,而是关于\(\rho\)的函数,而这个关于\(\rho\)的函数随着\(\rho\)的轨迹便是圆的边缘线。
这个函数怎么得出的?\(\rho=2\cos\theta\to\theta=\arccos{\frac{\rho}{2} }\)


反常积分

积分方法收集

\[\Gamma(n)=\int^{+\infty}_0x^{n-1}e^{-x}dx\]
\[\Gamma(n)=(n-1)!\]
\[\Gamma(\frac{1}{2})=\sqrt{\pi}\]


\[\int_0^{\infty}e^{-x^2}dx=\frac{\sqrt{\pi} }{2}\]


\[\int xe^xdx=\int (xe^x+e^x-e^x)dx=(x-1)e^x+C\]


\[\int \frac{dx}{\sin x}=\int \frac{dx}{2\sin \frac{x}{2}\cos \frac{x}{2} }=\int \frac{\sec^2 \frac{x}{2} d \frac{x}{2} }{\tan \frac{x}{2} }=\int \frac{d\tan \frac{x}{2} }{\tan \frac{x}{2} }=\ln (\tan \frac{x}{2})+C\]


\[\int \frac{1}{1+e^x}dx=\int \frac{e^{-x} }{1+e^{-x} }dx=-\int \frac{1}{1+e^{-x} }d(1+e^{-x})=-\ln (1+e^{-x})+C\]


\[\int \sqrt{\frac{1-t}{1+t} }dt\to令\frac{1-t}{1+t}=u^2\to t^2=\frac{1-u}{1+u}\]
\[dt=\frac{-4u}{(1+u^2)^2}du\to \int \frac{-4u^2}{(1+u^2)^2}du=-4\int(\frac{1}{1+u^2}-\frac{1}{(1+u^2)^2})du\]
后面部分令\(u=\tan\theta\),即可计算出。