Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(math/poly/fft): 修改递归版 FFT 代码实现 #5573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sunlight-zero
Copy link
Contributor

原来的 FFT 中,定义了旋转角度 step,并通过 cur *= step 不断计算下一个单位根。这种做法会随着循环逐渐累积浮点数的精度误差,最终误差太大,在洛谷模板题 P3803 会 WA。因此修改为直接调用 sin,cos 计算每一次的单位根。

  • 我已认真阅读贡献指南 (contributing guidelines) 和社区公约 (code of conduct),并遵循了如何参与页及格式手册页的相应规范。

原来的 FFT 中,定义了旋转角度 step,并通过 cur *= step 不断计算下一个单位根。这种做法会随着循环逐渐累积浮点数的精度误差,最终误差太大,在洛谷模板题 P3803 会 WA。因此修改为直接调用 sin,cos 计算每一次的单位根。
@Tiphereth-A
Copy link
Member

用三次变两次写法的话两版差别不是很大,都要加一些偏移量,而且新版的用时反而更长了…… 🤔

old new

@Sunlight-zero
Copy link
Contributor Author

我这边是修改前 WA,修改后刚好卡过……
WA AC
这道题时间挺紧张,应该是想卡递归 FFT,不过 XCPC 一般不会卡常吧,个人认为精度更重要一些。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants