mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
parent
d2d46051d3
commit
2d8749d2cf
72
S2OJ/98/98.cpp
Normal file
72
S2OJ/98/98.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const double PI = std::acos(-1);
|
||||
|
||||
void FFT(std::vector<std::complex<double>>& a) {
|
||||
if (a.size() == 1) return;
|
||||
|
||||
int m = a.size() >> 1;
|
||||
std::vector<std::complex<double>> a0, a1;
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
a0.emplace_back(a[i << 1]);
|
||||
a1.emplace_back(a[i << 1 | 1]);
|
||||
}
|
||||
|
||||
FFT(a0), FFT(a1);
|
||||
|
||||
std::complex<double>
|
||||
w0{std::cos(PI / m), std::sin(PI / m)},
|
||||
w1{1.0, 0.0};
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
a[i] = a0[i] + w1 * a1[i];
|
||||
a[i + m] = a0[i] - w1 * a1[i];
|
||||
w1 *= w0;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int n, m;
|
||||
|
||||
cin >> n >> m;
|
||||
|
||||
int k = 1 << (std::__lg(n + m) + 1);
|
||||
std::vector<std::complex<double>> f(k), g(k);
|
||||
|
||||
for (int i = 0; i <= n; i++) {
|
||||
cin >> f[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i <= m; i++) {
|
||||
cin >> g[i];
|
||||
}
|
||||
|
||||
FFT(f), FFT(g);
|
||||
|
||||
for (int i = 0; i < k; i++) {
|
||||
f[i] *= g[i];
|
||||
}
|
||||
|
||||
FFT(f);
|
||||
std::reverse(f.begin() + 1, f.end());
|
||||
|
||||
for (int i = 0; i <= n + m; i++) {
|
||||
cout << static_cast<int>(std::round(f[i].real() / k)) << ' ';
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/98/data/data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data11.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data12.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data13.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data14.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data14.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data15.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data15.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data16.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data16.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data17.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data17.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data18.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data18.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data18.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data19.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data19.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data20.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data20.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data20.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/data9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/data9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/ex_data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/ex_data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/ex_data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/ex_data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/98/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/98/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user