Advertisement
O_Egor

31

May 13th, 2022
735
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <tuple>
  7. using namespace std;
  8.  
  9. int main()
  10. {  
  11.     vector < tuple<int, int, int>> ans;
  12.     for (int i = 87921; i < 88187 + 1; ++i)
  13.     {
  14.         int tmp = i, sum(0), prod(1);
  15.         while (tmp)
  16.         {
  17.             sum += tmp % 10;
  18.             prod *= tmp % 10;
  19.             tmp /= 10;
  20.         }
  21.         if (prod != 0)
  22.         {
  23.             ans.push_back(make_tuple( prod, sum, i ));
  24.         }
  25.     }
  26.     sort(ans.begin(), ans.end());
  27.     for (int i = 0; i < ans.size(); ++i)
  28.         cout << get<2>(ans[i]) << ' ' << get<1>(ans[i]) << ' ' << get<0>(ans[i]) << '\n';
  29.     return 0;
  30. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement