fork(7) download
  1. ///FFT
  2.  
  3. typedef complex<ld> cld;
  4. complex<ld> a[MAXN], ya[MAXN], yb[MAXN], yt[MAXN], a1[MAXN], a2[MAXN];
  5.  
  6. /// a->y, sign = 1 | y->a, sign = -1
  7. void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
  8. if(n <= 1) {
  9. y[q] = a[p]; return;
  10. }
  11. complex<ld> en = exp(complex<ld>(0, sign*2*PI/n));
  12. complex<ld> e = 1;
  13. fft(a, y, n/2, sign, p, s*2, q);
  14. fft(a, y, n/2, sign, p + s, s*2, q + n/2);
  15. REP(i, 0, n/2) {
  16. yt[i] = y[q+i] + e * y[q+n/2+i];
  17. yt[i+n/2] = y[q+i] - e * y[q+n/2+i];
  18. e *= en;
  19. }
  20. REP(i, 0, n) y[q+i] = yt[i];
  21. }
  22.  
  23. void multiply(cld a[], cld b[], cld res[], int n) {
  24. fft(a, ya, n);
  25. fft(b, yb, n);
  26. REP(i, 0, n) ya[i] *= yb[i];
  27. fft(ya, res, n, -1);
  28. REP(i, 0, n) res[i] = llroundl(real(yb[i])/n);
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:9: error: ‘complex’ does not name a type
 typedef complex<ld> cld;
         ^
prog.cpp:4:1: error: ‘complex’ does not name a type
 complex<ld> a[MAXN], ya[MAXN], yb[MAXN], yt[MAXN], a1[MAXN], a2[MAXN];
 ^
prog.cpp:7:10: error: variable or field ‘fft’ declared void
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
          ^
prog.cpp:7:10: error: ‘complex’ was not declared in this scope
prog.cpp:7:18: error: ‘ld’ was not declared in this scope
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                  ^
prog.cpp:7:22: error: ‘a’ was not declared in this scope
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                      ^
prog.cpp:7:24: error: expected primary-expression before ‘]’ token
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                        ^
prog.cpp:7:27: error: ‘complex’ was not declared in this scope
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                           ^
prog.cpp:7:35: error: ‘ld’ was not declared in this scope
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                                   ^
prog.cpp:7:39: error: ‘y’ was not declared in this scope
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                                       ^
prog.cpp:7:41: error: expected primary-expression before ‘]’ token
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                                         ^
prog.cpp:7:44: error: expected primary-expression before ‘int’
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                                            ^
prog.cpp:7:51: error: expected primary-expression before ‘int’
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                                                   ^
prog.cpp:7:65: error: expected primary-expression before ‘int’
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                                                                 ^
prog.cpp:7:76: error: expected primary-expression before ‘int’
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                                                                            ^
prog.cpp:7:87: error: expected primary-expression before ‘int’
 void fft(complex<ld> a[], complex<ld> y[], int n, int sign = 1, int p = 0, int s = 1, int q = 0) {
                                                                                       ^
stdout
Standard output is empty