# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
32092 | h0ngjun7 | 씽크스몰 (kriii3_TT) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <complex>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const double M_PI = 3.1415926535897932384626433832795;
namespace FFT {
typedef complex<double> base;
void FFT(vector <base> &v, bool inv) {
vector<base> w(v.size());
for (int i = 0; i < v.size(); i++) {
int k = i&-i;
if (i == k) {
double ang = 2 * M_PI * i / v.size();
if (inv) ang *= -1;
w[i] = base(cos(ang), sin(ang));
}
else w[i] = w[i - k] * w[k];
}
for (int i = 1, j = 0; i < v.size(); i++) {
int bit = v.size() >> 1;
for (; j >= bit; bit >>= 1) j -= bit;
j += bit;
if (i < j) swap(v[i], v[j]);
}
for (int i = 2; i <= v.size(); i <<= 1) {