Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <time.h>
- #include <chrono>
- class Timer
- {
- public:
- Timer() : beg_(clock_::now()) {}
- void reset() { beg_ = clock_::now(); }
- double elapsed() const {
- return std::chrono::duration_cast<second_>
- (clock_::now() - beg_).count();
- }
- private:
- typedef std::chrono::high_resolution_clock clock_;
- typedef std::chrono::duration<double, std::ratio<1> > second_;
- std::chrono::time_point<clock_> beg_;
- };
- int main()
- {
- for (int i = 0; i < 50; i++)
- {
- Timer time;
- for (int j = 0; j < 1000;j++)
- {
- float rez = 0;
- double a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- int sol = 0;
- do {
- rez = a[0] + 13 * a[1] / a[2] + a[3] + 12 * a[4] - a[5] - 11 + a[6] * a[7] / a[8] - 10;
- if (rez == 66) {
- sol += 1;
- //std::cout << a[0] << a[1] << a[2] << a[3] << a[4] << a[5] << a[6] << a[7] << a[8]<<"\n";
- }
- if (sol == 10) break;
- } while (std::next_permutation(a, a + 9));
- }
- std::cout << time.elapsed() << "\n";
- }
- int zz = 0;
- std::cin >>zz;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement