Advertisement
Guest User

cucu

a guest
May 27th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <time.h>
  4. #include <chrono>
  5.  
  6. class Timer
  7. {
  8. public:
  9.     Timer() : beg_(clock_::now()) {}
  10.     void reset() { beg_ = clock_::now(); }
  11.     double elapsed() const {
  12.         return std::chrono::duration_cast<second_>
  13.             (clock_::now() - beg_).count();
  14.     }
  15.  
  16. private:
  17.     typedef std::chrono::high_resolution_clock clock_;
  18.     typedef std::chrono::duration<double, std::ratio<1> > second_;
  19.     std::chrono::time_point<clock_> beg_;
  20. };
  21.  
  22. int main()
  23. {
  24.     for (int i = 0; i < 50; i++)
  25.     {
  26.  
  27.         Timer time;    
  28.         for (int j = 0; j < 1000;j++)
  29.         {
  30.         float rez = 0;
  31.         double a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  32.         int sol = 0;
  33.         do {
  34.             rez = a[0] + 13 * a[1] / a[2] + a[3] + 12 * a[4] - a[5] - 11 + a[6] * a[7] / a[8] - 10;
  35.             if (rez == 66) {
  36.                 sol += 1;
  37.                 //std::cout << a[0] << a[1] << a[2] << a[3] << a[4] << a[5] << a[6] << a[7] << a[8]<<"\n";
  38.             }
  39.             if (sol == 10) break;
  40.         } while (std::next_permutation(a, a + 9));
  41.         }
  42.         std::cout << time.elapsed() << "\n";
  43.     }  
  44.     int zz = 0;
  45.     std::cin >>zz;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement