Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
1,872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #pragma GCC optimize("Ofast")
  2. #pragma GCC target("avx,avx2,fma")
  3. #include <bits/stdc++.h>
  4. /*
  5. struct Complex { double x, y; };
  6. Complex operator*(Complex lhs, Complex rhs) {
  7.     return Complex{lhs.x * rhs.x - lhs.y * rhs.y, lhs.x * rhs.y + lhs.y * rhs.x};
  8. }
  9. Complex& operator+=(Complex& lhs, Complex rhs) {
  10.     lhs.x += rhs.x;
  11.     lhs.y += rhs.y;
  12.     return lhs;
  13. }
  14. std::ostream& operator<<(std::ostream& os, Complex c) {
  15.     std::cout << "(" << c.x << "," << c.y << ")";
  16. }
  17. */
  18. using Complex = std::complex<double>;
  19. int main() {
  20.     std::mt19937 gen(123);
  21.     std::uniform_real_distribution<double> dist(-1,1);
  22.     std::vector<Complex> arr(25000);
  23.     for (auto &it : arr) {
  24.         it = Complex{dist(gen), dist(gen)};
  25.     }
  26.     Complex res{0,0};
  27.     for (auto it : arr) {
  28.         for (auto jt : arr) {
  29.             res += it * jt;
  30.         }
  31.     }
  32.     std::cout << res;
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement