Submission #15047

#TimeUsernameProblemLanguageResultExecution timeMemory
15047hongjun7씽크스몰 (kriii3_TT)C++98
Compilation error
0 ms0 KiB
#include <cstdio> #define _USE_MATH_DEFINES #include <math.h> #include <complex> #include <vector> #include <algorithm> using namespace std; #define sz(v) ((int)(v).size()) #define all(v) (v).begin(),(v).end() typedef complex<double> base; void fft(vector <base> &a, bool invert) { int n = sz(a); for (int i = 1, j = 0; i<n; i++) { int bit = n >> 1; for (; j >= bit; bit >>= 1) j -= bit; j += bit; if (i < j) swap(a[i], a[j]); } for (int len = 2; len <= n; len <<= 1) { double ang = 2 * M_PI / len*(invert ? -1 : 1); base wlen(cos(ang), sin(ang)); for (int i = 0; i<n; i += len) { base w(1); for (int j = 0; j<len / 2; j++) { base u = a[i + j], v = a[i + j + len / 2] * w; a[i + j] = u + v; a[i + j + len / 2] = u - v; w *= wlen; } } } if (invert) { for (int i = 0; i<n; i++) a[i] /= n; } } void multiply(const vector<int> &a, const vector<int> &b, vector<long long> &res) { vector <base> fa(all(a)), fb(all(b)); int n = 1; while (n <= max(sz(a), sz(b))) n <<= 1; fa.resize(n); fb.resize(n); fft(fa, false); fft(fb, false); for (int i = 0; i<n; i++) fa[i] *= fb[i]; fft(fa, true); res.resize(n); for (int i = 0; i < n; i++) res[i] = long long(fa[i].real() + (fa[i].real()>0 ? 0.5 : -0.5)); long long r = res[0]; for (int i = 1; i < n; i++) { long long x = res[i]; r ^= res[i]; } printf("%lld", r); } int n, m, x; int main() { scanf("%d%d", &n, &m); vector <int> a(n + 1), b(m + 1); vector <long long> res; for (int i = 0; i <= n; i++) scanf("%d", &a[i]); for (int i = 0; i <= m; i++) scanf("%d", &b[i]); multiply(a, b, res); }

Compilation message (stderr)

tt.cpp: In function ‘void multiply(const std::vector<int>&, const std::vector<int>&, std::vector<long long int>&)’:
tt.cpp:45:39: error: expected primary-expression before ‘long’
  for (int i = 0; i < n; i++) res[i] = long long(fa[i].real() + (fa[i].real()>0 ? 0.5 : -0.5));
                                       ^
tt.cpp:48:13: warning: unused variable ‘x’ [-Wunused-variable]
   long long x = res[i];
             ^
tt.cpp: In function ‘int main()’:
tt.cpp:55:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
                       ^
tt.cpp:58:49: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0; i <= n; i++) scanf("%d", &a[i]);
                                                 ^
tt.cpp:59:49: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0; i <= m; i++) scanf("%d", &b[i]);
                                                 ^