Advertisement
Guest User

Untitled

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