QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 1024 MB 总分: 100

#10700. 马吕斯定律

统计

很久以前,当 Tseng 博士还不是一位著名的物理学家时,他曾获得过国际光学奥林匹克竞赛(OIO)的金牌。作为奖励,他收到了一套偏振片。

当偏振光通过偏振片时,光强的变化可以通过以下公式计算:

$$I = I_0 \cos^2(|\theta_0 - \theta_1|)$$

其中: $I$ 是光通过偏振片后的强度, $I_0$ 是光通过偏振片前的初始强度, $\theta_0$ 是光的初始偏振方向, $\theta_1$ 是偏振片的透振方向,同时也是光通过偏振片后的偏振方向。

马吕斯定律(维基百科)

如果 $\theta_0 = 0^\circ$ 且 $\theta_1 = 90^\circ$,光会被完全阻挡。然而,Tseng 很快发现,在光源和第一个偏振片之间插入另一个 $45^\circ$ 的偏振片后,强度变为:

$$I = I_0 \cos^2(|0^\circ - 45^\circ|) \cos^2(|45^\circ - 90^\circ|) = \frac{1}{4}I_0$$

现在,Tseng 有一个光源,它发射初始偏振方向为 $\varphi$ 的偏振光。他还有 $N$ 个偏振片,其透振方向分别为 $\theta_1, \theta_2, \dots, \theta_N$。假设光的初始强度为 $1.0$。如果 Tseng 以最佳顺序排列这些偏振片,光通过所有偏振片后的最大强度是多少?

输入格式

第一行包含一个整数 $T$,表示测试用例的数量 ($1 \le T \le 10^5$)。

每个测试用例的第一行包含两个整数 $N$ 和 $\varphi$:偏振片的数量和光的初始偏振方向(以度为单位,$1 \le N \le 10^5; 0 \le \varphi < 360$)。

每个测试用例的第二行包含 $N$ 个整数 $\theta_1, \theta_2, \dots, \theta_N$:偏振片的透振方向(以度为单位,$0 \le \theta_i < 360$)。

所有测试用例的 $N$ 之和不超过 $10^5$。

输出格式

输出光通过所有偏振片后可能达到的最大强度。

如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则该答案将被接受。形式上,设你的答案为 $a$,标准答案为 $b$,如果满足 $\frac{|a-b|}{\max(1,|b|)} \le 10^{-6}$,则你的答案被视为正确。

样例

样例输入 1

3
1 0
90
2 0
45 90
5 0
1 2 3 4 5

样例输出 1

0.00000000000000
0.25000000000000
0.99847799499451

样例输入 2

2
5 180
0 60 120 240 300
4 333
239 100 41 5

样例输出 2

0.06250000000000
0.24250943127818

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.